diff --git a/Java/scripts/build.sh b/Java/scripts/build.sh index 613d20e..c5b6b67 100755 --- a/Java/scripts/build.sh +++ b/Java/scripts/build.sh @@ -5,5 +5,13 @@ javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp $ printf "\n\n\nRunning Program...\n\n" ORIGINAL_LOC=$(pwd) cd $OUT_DIR -java -cp .:../lib/bin -Djava.library.path="${LIBRARY_PATH}" ${MAIN_CLASS} "$@" +if java ${CUSTOM_PARAMS} -cp .:../lib/bin/ -XX:+UseZGC -Djava.library.path="${LIBRARY_PATH}" ${MAIN_CLASS} "$@"; then + ${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh + exit +fi +if java ${CUSTOM_PARAMS} -cp .:../lib/bin/ -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Djava.library.path="${LIBRARY_PATH}" ${MAIN_CLASS} "$@"; then + ${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh + exit +fi +java ${CUSTOM_PARAMS} -cp .:../lib/bin/ -XX:+PrintCommandLineFlags -Djava.library.path="${LIBRARY_PATH}" ${MAIN_CLASS} "$@" ${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh \ No newline at end of file diff --git a/Java/scripts/build2.sh b/Java/scripts/build2.sh new file mode 100644 index 0000000..53fe062 --- /dev/null +++ b/Java/scripts/build2.sh @@ -0,0 +1,17 @@ +#Builds and runs the project for Windows. +#Java +source ${LANGUAGE}/scripts/version_info +javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp ${CLASS_PATH_WINDOWS} -d ${OUT_DIR} ${PROJECT_DIR}/*.java +printf "\n\n\nRunning Program...\n\n" +ORIGINAL_LOC=$(pwd) +cd $OUT_DIR +if java ${CUSTOM_PARAMS} -cp ".;../lib/bin/" -XX:+UseZGC "-Djava.library.path=${LIBRARY_PATH}" ${MAIN_CLASS} "$@"; then + ${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh + exit +fi +if java ${CUSTOM_PARAMS} -cp ".;../lib/bin/" -XX:+UnlockExperimentalVMOptions -XX:+UseZGC "-Djava.library.path=${LIBRARY_PATH}" ${MAIN_CLASS} "$@"; then + ${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh + exit +fi +java ${CUSTOM_PARAMS} -cp ".;../lib/bin/" -XX:+PrintCommandLineFlags "-Djava.library.path=${LIBRARY_PATH}" ${MAIN_CLASS} "$@" +${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh \ No newline at end of file diff --git a/Java/scripts/filelist b/Java/scripts/filelist index 455d98e..9e5004d 100644 --- a/Java/scripts/filelist +++ b/Java/scripts/filelist @@ -1,7 +1,10 @@ +build2.sh build.sh clean.sh commit.sh +jar2.sh jar.sh release.sh update.sh version_info +zip.sh diff --git a/Java/scripts/jar.sh b/Java/scripts/jar.sh index d201c59..61d1759 100755 --- a/Java/scripts/jar.sh +++ b/Java/scripts/jar.sh @@ -5,13 +5,13 @@ rm -Rf bin/* javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp ${CLASS_PATH} -d ${OUT_DIR} ${PROJECT_DIR}/${PROJECT_NAME}.java printf "\n\n\nGenerating Manifest...\n\n" touch manifest -echo "Main-Class: ${MAIN_CLASS}" >> manifest +echo "Main-Class: ${MAIN_CLASS}" > manifest printf "\n\n\nCreating Jar...\n\n" ORIGINAL_LOC=$(pwd) cd ${OUT_DIR} jar cfm ${PROJECT_NAME}.jar ${ORIGINAL_LOC}/manifest sig jar uf ${PROJECT_NAME}.jar -C ../lib/bin/ . printf "\n\n\nRunning Program...\n\n" -java -cp .:../lib/bin -Djava.library.path="${LIBRARY_PATH}" -jar ${PROJECT_NAME}.jar "$@" -../${LANGUAGE}/scripts/clean.sh +java ${CUSTOM_PARAMS} -cp .:../lib/bin -Djava.library.path="${LIBRARY_PATH}" -jar ${PROJECT_NAME}.jar "$@" +${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh cd .. diff --git a/Java/scripts/jar2.sh b/Java/scripts/jar2.sh new file mode 100644 index 0000000..9167bb8 --- /dev/null +++ b/Java/scripts/jar2.sh @@ -0,0 +1,17 @@ +#Builds a runnable jar file using ${MAIN_CLASS} as an entry point and then runs the newly generated jar for Windows. +#Java +source ${LANGUAGE}/scripts/version_info +rm -Rf bin/* +javac -source ${SOURCE_VERSION} -target ${TARGET_VERSION} -Xlint:unchecked -cp ${CLASS_PATH_WINDOWS} -d ${OUT_DIR} ${PROJECT_DIR}/${PROJECT_NAME}.java +printf "\n\n\nGenerating Manifest...\n\n" +touch manifest +echo "Main-Class: ${MAIN_CLASS}" > manifest +printf "\n\n\nCreating Jar...\n\n" +ORIGINAL_LOC=$(pwd) +cd ${OUT_DIR} +jar cfm ${PROJECT_NAME}.jar ${ORIGINAL_LOC}/manifest sig +jar uf ${PROJECT_NAME}.jar -C ../lib/bin/ . +printf "\n\n\nRunning Program...\n\n" +java ${CUSTOM_PARAMS} -cp .;../lib/bin "-Djava.library.path=${LIBRARY_PATH}" -jar ${PROJECT_NAME}.jar "$@" +${ORIGINAL_LOC}/${LANGUAGE}/scripts/clean.sh +cd .. diff --git a/Java/scripts/md5 b/Java/scripts/md5 index 6ae0752..b2c3eed 100644 --- a/Java/scripts/md5 +++ b/Java/scripts/md5 @@ -1,6 +1,9 @@ -build.sh:22308eae5fd9c88aa16fef54cf03ae21 - +build2.sh:b1c6b7c6b2eb19ba54be6824bda8805b - +build.sh:5df470d49036bf7565493739aeebeaa8 - clean.sh:668a2f9b568c55f6a044a509315032f6 - commit.sh:5e4448db9ad48e72ec3a1ff4f5763b41 - -jar.sh:343cf505530401fb696296bc25a9b090 - -release.sh:b1b62203411b18d0fec1db3dc2e5a061 - +jar2.sh:7977fc138ee5db798d08c34734f0be93 - +jar.sh:821d5a109324d405f05c35c4bb129375 - +release.sh:027178aa6da76180401a188d8f03af64 - update.sh:3be721658983183efa395984acd96b03 - +zip.sh:273f5a83b80a8e54022d60514dfeec0a - diff --git a/Java/scripts/release.sh b/Java/scripts/release.sh index 0f7389c..fca8c4b 100644 --- a/Java/scripts/release.sh +++ b/Java/scripts/release.sh @@ -1,14 +1,28 @@ -#Creates a zip file containing all project contents. +#Use ./sig release to create a custom installer based on OS. #Java source ${LANGUAGE}/scripts/version_info -TARGET_FILE="${PROJECT_NAME}_${RELEASE_VERSION}.zip" FILES=$(cat ${LANGUAGE}/scripts/.package.files) -echo "Creating Package $TARGET_FILE..." -for f in $FILES -do - zip -ur $TARGET_FILE $f -done -echo "Complete!" -echo "" -echo "" -echo "" \ No newline at end of file +if [ "$1" = "windows" ];then + echo "Creating a package for Windows..." + echo "Not implemented yet." +elif [ "$1" = "mac" ];then + echo "Creating a package for Mac..." + echo "Not implemented yet." +elif [ "$1" = "linux" ];then + echo "Creating a package for Linux..." + cd .. + mkdir -vp RabiCloneOut/in + for f in $FILES + do + cp -Rv --parents $PROJECT_NAME/$f RabiCloneOut/in + done + jpackage --verbose --input RabiCloneOut/in/RabiClone --main-jar bin/RabiClone.jar --main-class sig.RabiClone --type app-image --dest RabiCloneOut + cp -Rv RabiCloneOut/RabiClone/lib/app/* RabiCloneOut/RabiClone + jpackage --verbose --app-image RabiCloneOut/RabiClone --name RabiClone + rm -Rfv RabiCloneOut + cd RabiClone + echo "Done!" +else + echo "Usage: " + echo " ./sig release " +fi \ No newline at end of file diff --git a/Java/scripts/zip.sh b/Java/scripts/zip.sh new file mode 100644 index 0000000..4de5b1a --- /dev/null +++ b/Java/scripts/zip.sh @@ -0,0 +1,14 @@ +#Create a zip folder containing all dependencies. For quick release. +#Java +source ${LANGUAGE}/scripts/version_info +TARGET_FILE="${PROJECT_NAME}_${RELEASE_VERSION}.zip" +FILES=$(cat ${LANGUAGE}/scripts/.package.files) +echo "Creating Package $TARGET_FILE..." +for f in $FILES +do + zip -ur $TARGET_FILE $f +done +echo "Complete!" +echo "" +echo "" +echo "" \ No newline at end of file diff --git a/bin/JavaProjectTemplate.jar b/bin/JavaProjectTemplate.jar deleted file mode 100644 index 37133e2..0000000 Binary files a/bin/JavaProjectTemplate.jar and /dev/null differ diff --git a/manifest b/manifest new file mode 100644 index 0000000..7c17694 --- /dev/null +++ b/manifest @@ -0,0 +1 @@ +Main-Class: sig.MultiRando diff --git a/sig b/sig index e4830e8..abc80f0 100755 --- a/sig +++ b/sig @@ -1,11 +1,15 @@ -export AUTO_UPDATE=true +export AUTO_UPDATE=false source utils/define.sh -define PROJECT_NAME "JavaProjectTemplate" +define PROJECT_NAME "MultiRando" define PROJECT_DIR "src/sig" define MAIN_CLASS "sig.${PROJECT_NAME}" define OUT_DIR "bin" +define LIBRARY_PATH "../lib" +define CLASS_PATH "${PROJECT_DIR}/..:lib/bin" +define CLASS_PATH_WINDOWS "${PROJECT_DIR}/..;lib/bin" +define CUSTOM_PARAMS "" define LANGUAGE "Java" source utils/main.sh \ No newline at end of file diff --git a/src/sig/JavaProjectTemplate.java b/src/sig/JavaProjectTemplate.java deleted file mode 100644 index ac5ae34..0000000 --- a/src/sig/JavaProjectTemplate.java +++ /dev/null @@ -1,21 +0,0 @@ -package sig; - -import javax.swing.JFrame; -import sig.engine.Panel; - -public class JavaProjectTemplate { - public static final String PROGRAM_NAME="Sig's Java Project Template"; - public static void main(String[] args) { - JFrame f = new JFrame(PROGRAM_NAME); - Panel p = new Panel(f); - - p.init(); - - f.add(p); - f.setSize(1280,720); - f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - f.setVisible(true); - - p.render(); - } -} diff --git a/src/sig/MultiRando.java b/src/sig/MultiRando.java new file mode 100644 index 0000000..3f2a2d8 --- /dev/null +++ b/src/sig/MultiRando.java @@ -0,0 +1,7 @@ +package sig; + +public class MultiRando { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/src/sig/engine/Color.java b/src/sig/engine/Color.java deleted file mode 100644 index 3a6bde7..0000000 --- a/src/sig/engine/Color.java +++ /dev/null @@ -1,38 +0,0 @@ -package sig.engine; - -public class Color { - int r,g,b,a; - - final static public Color BLACK = new Color(0,0,0); - final static public Color RED = new Color(204,0,0); - final static public Color GREEN = new Color(78,154,6); - final static public Color YELLOW = new Color(196,160,0); - final static public Color BLUE = new Color(114,159,207); - final static public Color MAGENTA = new Color(117,80,123); - final static public Color CYAN = new Color(6,152,154); - final static public Color WHITE = new Color(211,215,207); - final static public Color BRIGHT_BLACK = new Color(85,87,83); - final static public Color BRIGHT_RED = new Color(239,41,41); - final static public Color BRIGHT_GREEN = new Color(138,226,52); - final static public Color BRIGHT_YELLOW = new Color(252,233,79); - final static public Color BRIGHT_BLUE = new Color(50,175,255); - final static public Color BRIGHT_MAGENTA = new Color(173,127,168); - final static public Color BRIGHT_CYAN = new Color(52,226,226); - final static public Color BRIGHT_WHITE = new Color(255,255,255); - - public Color(int r, int g, int b) { - this(r,g,b,255); - } - - public Color(int r, int g, int b,int a) { - super(); - this.r = r; - this.g = g; - this.b = b; - this.a = a; - } - - public int getColor() { - return (a<<24)+(r<<16)+(g<<8)+b; - } -} diff --git a/src/sig/engine/Edge.java b/src/sig/engine/Edge.java deleted file mode 100644 index 867937e..0000000 --- a/src/sig/engine/Edge.java +++ /dev/null @@ -1,33 +0,0 @@ -package sig.engine; - -public class Edge { - Point a,b; - int min_y; - int max_y; - int min_x; - int max_x; - double x_of_min_y; - double inverse_slope; - public Edge(Point a, Point b) { - super(); - this.a = a; - this.b = b; - min_y=Math.min(a.y, b.y); - max_y=Math.max(a.y, b.y); - min_x=Math.min(a.x, b.x); - max_x=Math.max(a.x, b.x); - if (a.y==min_y) { - x_of_min_y=a.x; - } else { - x_of_min_y=b.x; - } - - inverse_slope=(double)(a.x-b.x)/(a.y-b.y); - } - @Override - public String toString() { - return "Edge [a=" + a + ", b=" + b + ", min_y=" + min_y + ", max_y=" + max_y + ", min_x=" + min_x + ", max_x=" - + max_x + ", x_of_min_y=" + x_of_min_y + ", inverse_slope=" + inverse_slope + "]"; - } - -} diff --git a/src/sig/engine/Panel.java b/src/sig/engine/Panel.java deleted file mode 100644 index 2f558f7..0000000 --- a/src/sig/engine/Panel.java +++ /dev/null @@ -1,314 +0,0 @@ -package sig.engine; -import java.awt.Graphics; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsEnvironment; -import java.awt.Image; -import java.awt.Toolkit; -import java.awt.image.ColorModel; -import java.awt.image.MemoryImageSource; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JFrame; -import javax.swing.JPanel; - -import sig.JavaProjectTemplate; - -public class Panel extends JPanel implements Runnable { - JFrame window; - public int pixel[]; - public int width=1280; - public int height=720; - final int CIRCLE_PRECISION=32; - final int OUTLINE_COL=Color.BRIGHT_WHITE.getColor(); - private Thread thread; - private Image imageBuffer; - private MemoryImageSource mImageProducer; - private ColorModel cm; - int scanLine=0; - int nextScanLine=0; - double x_offset=0; - double y_offset=0; - int frameCount=0; - long lastSecond=0; - int lastFrameCount=0; - - public Panel(JFrame f) { - super(true); - this.window=f; - thread = new Thread(this, "MyPanel Thread"); - } - - /** - * Get Best Color model available for current screen. - * @return color model - */ - protected static ColorModel getCompatibleColorModel(){ - GraphicsConfiguration gfx_config = GraphicsEnvironment. - getLocalGraphicsEnvironment().getDefaultScreenDevice(). - getDefaultConfiguration(); - return gfx_config.getColorModel(); - } - - /** - * Call it after been visible and after resizes. - */ - public void init(){ - cm = getCompatibleColorModel(); - int screenSize = width * height; - if(pixel == null || pixel.length < screenSize){ - pixel = new int[screenSize]; - } - if(thread.isInterrupted() || !thread.isAlive()){ - thread.start(); - } - mImageProducer = new MemoryImageSource(width, height, cm, pixel,0, width); - mImageProducer.setAnimated(true); - mImageProducer.setFullBufferUpdates(true); - imageBuffer = Toolkit.getDefaultToolkit().createImage(mImageProducer); - } - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - // perform draws on pixels - render(); - // ask ImageProducer to update image - mImageProducer.newPixels(); - // draw it on panel - g.drawImage(this.imageBuffer, 0, 0, this); - - - if (window!=null&&System.currentTimeMillis()-lastSecond>=1000) { - window.setTitle(JavaProjectTemplate.PROGRAM_NAME+" - FPS: "+(frameCount-lastFrameCount)); - lastFrameCount=frameCount; - lastSecond=System.currentTimeMillis(); - } - frameCount++; - } - - /** - * Overrides ImageObserver.imageUpdate. - * Always return true, assuming that imageBuffer is ready to go when called - */ - @Override - public boolean imageUpdate(Image image, int a, int b, int c, int d, int e) { - return true; - } - /** - * Do your draws in here !! - * pixel is your canvas! - */ - public /* abstract */ void render(){ - int[] p = pixel; // this avoid crash when resizing - //a=h/w - - for (int x=0;x edges_sorted = new ArrayList(); - for (int i=0;i=edges[i].min_y) { - edges_sorted.add(j,edges[i]); - inserted=true; - break; - } - } - if (!inserted) { - edges_sorted.add(edges[i]); - } - } - } - } - //System.out.println(edges_sorted); - List active_edges = new ArrayList(); - scanLine = edges_sorted.get(0).min_y-1; - nextScanLine = scanLine+1; - do { - for (int i=0;i=0) { - Draw(p,index,col.getColor()); - } - } - } - List new_active_edges = new ArrayList(); - for (int i=0;ie.x_of_min_y) { - new_active_edges.add(j,e); - inserted=true; - break; - } - } - if (!inserted) { - new_active_edges.add(e); - } - } - active_edges=new_active_edges; - GetNextScanLineEdges(edges_sorted, active_edges); - } - while (active_edges.size()>0); - } - - private void GetNextScanLineEdges(List edges_sorted, List active_edges) { - if (scanLine==nextScanLine) { - for (int i=0;iscanLine) { - nextScanLine=e.min_y; - break; - } - } - } - } - - public void Draw(int[] canvas,int index, int col) { - int alpha = col>>>24; - if (alpha==0) { - return;} - else - if (alpha==255) { - canvas[index]=col; - } else { - float ratio=alpha/255f; - int prev_col=canvas[index]; - int prev_r=(prev_col&0xFF); - int prev_g=(prev_col&0xFF00)>>>8; - int prev_b=(prev_col&0xFF0000)>>>16; - int r=(col&0xFF); - int g=(col&0xFF00)>>>8; - int b=(col&0xFF0000)>>>16; - - int new_r=(int)(ratio*r+(1-ratio)*prev_r); - int new_g=(int)(ratio*g+(1-ratio)*prev_g); - int new_b=(int)(ratio*b+(1-ratio)*prev_b); - - canvas[index]=new_r+(new_g<<8)+(new_b<<16)+(col&0xFF000000); - } - } - - @Override - public void run() { - while (true) { - // request a JPanel re-drawing - repaint(); - //System.out.println("Repaint "+frameCount++); - //try {Thread.sleep(1);} catch (InterruptedException e) {} - } - } -} \ No newline at end of file diff --git a/src/sig/engine/Point.java b/src/sig/engine/Point.java deleted file mode 100644 index b848018..0000000 --- a/src/sig/engine/Point.java +++ /dev/null @@ -1,32 +0,0 @@ -package sig.engine; - -public class Point { - int x,y; - - public Point(int x, int y) { - super(); - this.x = x; - this.y = y; - } - - public int getX() { - return x; - } - - public void setX(int x) { - this.x = x; - } - - public int getY() { - return y; - } - - public void setY(int y) { - this.y = y; - } - - @Override - public String toString() { - return "Point(" + x + "," + y + ")"; - } -} diff --git a/utils/.updateDirectories b/utils/.updateDirectories index e4dde11..0c078d1 100644 --- a/utils/.updateDirectories +++ b/utils/.updateDirectories @@ -1,3 +1,4 @@ Java/ +C/ scripts/ utils/ \ No newline at end of file diff --git a/utils/main.sh b/utils/main.sh index d299d6b..0a4c92a 100644 --- a/utils/main.sh +++ b/utils/main.sh @@ -25,4 +25,4 @@ if [ -z "$1" ] exit fi -./$LANGUAGE/scripts/$1.sh "${*:2}" \ No newline at end of file +./$LANGUAGE/scripts/$1.sh "${@:2}" \ No newline at end of file diff --git a/utils/md5 b/utils/md5 index baa339d..b8c2ada 100644 --- a/utils/md5 +++ b/utils/md5 @@ -1,4 +1,4 @@ define.sh:3ecab0dffe2adfb950f3eb7c7061b750 - -main.sh:d3d1bd0b56d8114eb7479964227f8576 - +main.sh:4e6e9f0650ec790ce2c4364db94f0caa - search.sh:81d08f5ff48e8a44b5f68387d426da05 - -.updateDirectories:0ede00461e947494545e694040787b3f - +.updateDirectories:fa5e95db12be22ae8aed7ecbc560e38c -