summaryrefslogtreecommitdiffstats
path: root/logo/src/xlogo/utils
diff options
context:
space:
mode:
authorMarko Živković <[email protected]>2014-06-11 10:10:33 +0000
committerMarko Živković <[email protected]>2014-06-11 10:10:33 +0000
commit1107aa0763e3d7554408c401d2a1dbed11a94c51 (patch)
tree7074264bc7b63f2ee5ee14a39458380fcce1904b /logo/src/xlogo/utils
Add initial directories and files
git-svn-id: https://svn.code.sf.net/p/xlogo4schools/svn/trunk@1 3b0d7934-f7ef-4143-9606-b51f2e2281fd
Diffstat (limited to 'logo/src/xlogo/utils')
-rw-r--r--logo/src/xlogo/utils/ExtensionFichier.java75
-rw-r--r--logo/src/xlogo/utils/Icon_x4s.pngbin0 -> 3795 bytes
-rw-r--r--logo/src/xlogo/utils/Logo_xlogo4schools.pngbin0 -> 4583 bytes
-rw-r--r--logo/src/xlogo/utils/Utils.java481
-rw-r--r--logo/src/xlogo/utils/WebPage.java66
-rw-r--r--logo/src/xlogo/utils/WriteImage.java122
-rw-r--r--logo/src/xlogo/utils/animation.pngbin0 -> 3427 bytes
-rw-r--r--logo/src/xlogo/utils/background.pngbin0 -> 13385 bytes
-rw-r--r--logo/src/xlogo/utils/chercher.pngbin0 -> 1784 bytes
-rw-r--r--logo/src/xlogo/utils/close_icon.pngbin0 -> 1029 bytes
-rw-r--r--logo/src/xlogo/utils/down_arrow.pngbin0 -> 979 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau0.pngbin0 -> 293 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau1.pngbin0 -> 1167 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau10.pngbin0 -> 373 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau11.pngbin0 -> 992 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau12.pngbin0 -> 217 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau13.pngbin0 -> 1528 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau2.pngbin0 -> 1783 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau3.pngbin0 -> 1523 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau4.pngbin0 -> 1630 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau5.pngbin0 -> 1178 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau6.pngbin0 -> 193 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau7.pngbin0 -> 5606 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau8.pngbin0 -> 1945 bytes
-rw-r--r--logo/src/xlogo/utils/drapeau9.pngbin0 -> 589 bytes
-rw-r--r--logo/src/xlogo/utils/editcopy.pngbin0 -> 1289 bytes
-rw-r--r--logo/src/xlogo/utils/editcut.pngbin0 -> 330 bytes
-rw-r--r--logo/src/xlogo/utils/editpaste.pngbin0 -> 2159 bytes
-rw-r--r--logo/src/xlogo/utils/error.pngbin0 -> 1469 bytes
-rw-r--r--logo/src/xlogo/utils/fileprint.pngbin0 -> 1610 bytes
-rw-r--r--logo/src/xlogo/utils/fog.pngbin0 -> 7561 bytes
-rw-r--r--logo/src/xlogo/utils/gnu_gpl.pngbin0 -> 23180 bytes
-rw-r--r--logo/src/xlogo/utils/icone.pngbin0 -> 16894 bytes
-rw-r--r--logo/src/xlogo/utils/info_icon.pngbin0 -> 4057 bytes
-rw-r--r--logo/src/xlogo/utils/light0.pngbin0 -> 11493 bytes
-rw-r--r--logo/src/xlogo/utils/light1.pngbin0 -> 11494 bytes
-rw-r--r--logo/src/xlogo/utils/light2.pngbin0 -> 11455 bytes
-rw-r--r--logo/src/xlogo/utils/light3.pngbin0 -> 11422 bytes
-rw-r--r--logo/src/xlogo/utils/menubtn.pngbin0 -> 1254 bytes
-rw-r--r--logo/src/xlogo/utils/play.pngbin0 -> 3877 bytes
-rw-r--r--logo/src/xlogo/utils/preview0.pngbin0 -> 1078 bytes
-rw-r--r--logo/src/xlogo/utils/preview1.pngbin0 -> 2552 bytes
-rw-r--r--logo/src/xlogo/utils/preview2.pngbin0 -> 3228 bytes
-rw-r--r--logo/src/xlogo/utils/preview3.pngbin0 -> 1471 bytes
-rw-r--r--logo/src/xlogo/utils/preview4.pngbin0 -> 3416 bytes
-rw-r--r--logo/src/xlogo/utils/preview5.pngbin0 -> 2996 bytes
-rw-r--r--logo/src/xlogo/utils/preview6.pngbin0 -> 1470 bytes
-rw-r--r--logo/src/xlogo/utils/quit.pngbin0 -> 760 bytes
-rw-r--r--logo/src/xlogo/utils/redo.pngbin0 -> 1601 bytes
-rw-r--r--logo/src/xlogo/utils/remove_256.pngbin0 -> 1227 bytes
-rw-r--r--logo/src/xlogo/utils/screenshot.pngbin0 -> 7472 bytes
-rw-r--r--logo/src/xlogo/utils/stop.pngbin0 -> 1056 bytes
-rw-r--r--logo/src/xlogo/utils/tortue0.pngbin0 -> 1369 bytes
-rw-r--r--logo/src/xlogo/utils/tortue1.pngbin0 -> 5105 bytes
-rw-r--r--logo/src/xlogo/utils/tortue2.pngbin0 -> 4305 bytes
-rw-r--r--logo/src/xlogo/utils/tortue3.pngbin0 -> 2014 bytes
-rw-r--r--logo/src/xlogo/utils/tortue4.pngbin0 -> 5255 bytes
-rw-r--r--logo/src/xlogo/utils/tortue5.pngbin0 -> 3993 bytes
-rw-r--r--logo/src/xlogo/utils/tortue6.pngbin0 -> 2456 bytes
-rw-r--r--logo/src/xlogo/utils/undo.pngbin0 -> 1489 bytes
-rw-r--r--logo/src/xlogo/utils/up_arrow.pngbin0 -> 986 bytes
-rw-r--r--logo/src/xlogo/utils/zoomin.pngbin0 -> 1628 bytes
-rw-r--r--logo/src/xlogo/utils/zoomout.pngbin0 -> 1588 bytes
63 files changed, 744 insertions, 0 deletions
diff --git a/logo/src/xlogo/utils/ExtensionFichier.java b/logo/src/xlogo/utils/ExtensionFichier.java
new file mode 100644
index 0000000..4fcf708
--- /dev/null
+++ b/logo/src/xlogo/utils/ExtensionFichier.java
@@ -0,0 +1,75 @@
+/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq
+ * Copyright (C) 2013 Marko Zivkovic
+ *
+ * Contact Information: marko88zivkovic at gmail dot com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version. This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details. You should have received a copy of the
+ * GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic
+ * during his Bachelor thesis at the computer science department of ETH Z�rich,
+ * in the year 2013 and/or during future work.
+ *
+ * It is a reengineered version of XLogo written by Lo�c Le Coq, published
+ * under the GPL License at http://xlogo.tuxfamily.org/
+ *
+ * Contents of this file were initially written by Lo�c Le Coq,
+ * modifications, extensions, refactorings might have been applied by Marko Zivkovic
+ */package xlogo.utils;
+import javax.swing.filechooser.*;
+import java.io.File;
+//Permet de filtrer les fichiers dans un FileChooser
+// You can add a filter in a FileChooser
+
+/**
+ * Title : XLogo
+ * Description : XLogo is an interpreter for the Logo
+ * programming language
+ * @author Loïc Le Coq
+ */
+public class ExtensionFichier extends FileFilter {
+/**
+ * @uml.property name="description"
+ */
+private String description; //Description du type de fichiers (Ex: "Fichiers JPEG")
+/**
+ * @uml.property name="extension" multiplicity="(0 -1)" dimension="1"
+ */
+private String[] extension; //Extension (incluant le '.') Ex: .jpg .java
+ public ExtensionFichier() {
+ }
+ public ExtensionFichier(String description,String[] extension){
+ this.description=description;
+ this.extension=extension;
+ }
+ public boolean accept(File f) {
+ if (f.isDirectory()) return true;
+ String nomFichier = f.getPath().toLowerCase();
+ for (int i=0;i<extension.length;i++){
+ if (nomFichier.endsWith(extension[i])) return true;
+
+ }
+ return false;
+ }
+ public String getDescription() {
+ StringBuffer sb=new StringBuffer();
+ sb.append(description);
+ sb.append(" (");
+ for (int i=0;i<extension.length;i++){
+ sb.append("*");
+ sb.append(extension[i]);
+ if (i!=extension.length-1) sb.append(", ");
+ }
+ sb.append(")");
+ return new String(sb);
+ }
+} \ No newline at end of file
diff --git a/logo/src/xlogo/utils/Icon_x4s.png b/logo/src/xlogo/utils/Icon_x4s.png
new file mode 100644
index 0000000..1cbd384
--- /dev/null
+++ b/logo/src/xlogo/utils/Icon_x4s.png
Binary files differ
diff --git a/logo/src/xlogo/utils/Logo_xlogo4schools.png b/logo/src/xlogo/utils/Logo_xlogo4schools.png
new file mode 100644
index 0000000..3898176
--- /dev/null
+++ b/logo/src/xlogo/utils/Logo_xlogo4schools.png
Binary files differ
diff --git a/logo/src/xlogo/utils/Utils.java b/logo/src/xlogo/utils/Utils.java
new file mode 100644
index 0000000..3c2e703
--- /dev/null
+++ b/logo/src/xlogo/utils/Utils.java
@@ -0,0 +1,481 @@
+/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq
+ * Copyright (C) 2013 Marko Zivkovic
+ *
+ * Contact Information: marko88zivkovic at gmail dot com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version. This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details. You should have received a copy of the
+ * GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic
+ * during his Bachelor thesis at the computer science department of ETH Z�rich,
+ * in the year 2013 and/or during future work.
+ *
+ * It is a reengineered version of XLogo written by Lo�c Le Coq, published
+ * under the GPL License at http://xlogo.tuxfamily.org/
+ *
+ * Contents of this file were initially written by Lo�c Le Coq,
+ * modifications, extensions, refactorings might have been applied by Marko Zivkovic
+ */
+
+/**
+ * Title : XLogo
+ * Description : XLogo is an interpreter for the Logo
+ * programming language
+ * @author Loïc Le Coq
+ */
+package xlogo.utils;
+import java.awt.Container;
+import java.awt.Font;
+import java.awt.Image;
+import java.awt.Component;
+import java.awt.Toolkit;
+import java.io.BufferedReader;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.StringTokenizer;
+
+import javax.swing.ImageIcon;
+
+import xlogo.kernel.MyCalculator;
+import xlogo.kernel.Affichage;
+import xlogo.storage.WSManager;
+import xlogo.storage.workspace.Language;
+import xlogo.Logo;
+
+public class Utils {
+
+ /**
+ * Marko : Here a technique was used for loading images, that happens to be from the last milenium.
+ * https://weblogs.java.net/blog/chet/archive/2004/07/imageio_just_an.html
+ *
+ * The way of the 3rs millenium is ImageIO
+ *
+ * @param nom
+ * @param jf
+ * @return
+ */
+ public static ImageIcon dimensionne_image(String name,Component jf){
+
+ Image img = Toolkit.getDefaultToolkit().getImage(Utils.class.getResource(name));
+
+ return new ImageIcon(img.getScaledInstance(20, 20, Image.SCALE_SMOOTH));
+
+ /*
+ Image image;
+ try
+ {
+ image = ImageIO.read(new File("xlogo/utils/"+nom));
+ return image.getScaledInstance(22, 22, Image.SCALE_SMOOTH);
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ / *
+ Image image=null;
+ image= Toolkit.getDefaultToolkit().getImage(Utils.class.getResource(nom));
+ MediaTracker tracker=new MediaTracker(jf);
+ tracker.addImage(image,0);
+ try{tracker.waitForID(0);}
+ catch(InterruptedException e1){}
+ double largeur_ecran=Toolkit.getDefaultToolkit().getScreenSize().getWidth();
+ int largeur=image.getWidth(jf);
+ int hauteur=image.getHeight(jf);
+ // On fait attention à la résolution de l'utilisateur
+ double facteur = largeur_ecran/1024.0; //les images sont prévues pour 1024x768
+ if ((int)(facteur+0.001)!=1){
+ image=image.getScaledInstance((int)(facteur*largeur),(int)(facteur*hauteur),Image.SCALE_SMOOTH);
+ tracker=new MediaTracker(jf);
+ tracker.addImage(image,0);
+ try{tracker.waitForID(0);}
+ catch(InterruptedException e1){}
+ }
+ return image;
+ */
+ }
+ public static void recursivelySetFonts(Component comp, Font font) {
+ comp.setFont(font);
+ if (comp instanceof Container) {
+ Container cont = (Container) comp;
+ for(int j=0, ub=cont.getComponentCount(); j<ub; ++j)
+ recursivelySetFonts(cont.getComponent(j), font);
+ }
+ }
+ public static String rajoute_backslash(String st){
+ StringBuffer tampon=new StringBuffer();
+ for(int j=0;j<st.length();j++){
+ char c=st.charAt(j);
+ if (c=='\\') tampon.append("\\\\");
+ else if (c==' ') tampon.append("\\e");
+ else if ("()[]#".indexOf(c)!=-1) tampon.append("\\"+c);
+ else tampon.append(c);
+ }
+ return(new String(tampon));
+ }
+
+ /**
+ * Escape string, backslash ...
+ * @param chaine
+ * @return
+ */
+ public static String SortieTexte(String chaine){ // Enlève les backslash
+ StringBuffer buffer=new StringBuffer();
+ boolean backslash=false;
+ boolean ignore=false;
+ for (int j=0;j<chaine.length();j++){
+ char c=chaine.charAt(j);
+ if (backslash) {
+ if (c=='e') buffer.append(' ');
+// else if (c=='\\') buffer.append('\\');
+ else if (c=='n') buffer.append("\n");
+ else if(c=='v') buffer.append("");
+ else if(c=='l') {
+ ignore=true;
+ }
+ else if("[]()#\\".indexOf(c)>-1) buffer.append(c);
+ backslash=false;
+ }
+ else {
+ if (c=='\\') backslash=true;
+ else if (!ignore) buffer.append(c);
+ else if (c==' ') ignore=false;
+ }
+ }
+ return MyCalculator.getOutputNumber(new String(buffer));
+ }
+ /**
+ * This method is formatting the String st.<br>
+ * - Unused white spaces are deleted.<br>
+ * - The character \ is modified to \\ <br>
+ * - The sequence "\ " is modified to "\e"<br>
+ * - The sequence "\ " is modified to "\e"<br>
+ * - The sequence "\ " is modified to "\e"<br>
+ * - The sequence "\ " is modified to "\e"<br>
+ * @param st The String instruction to format
+ * @return The formatted instructions
+ */
+ public static StringBuffer decoupe(String st) {
+ StringBuffer buffer = new StringBuffer();
+ // If last character is a white space
+ boolean espace=false;
+ // If last character is a backslash
+ boolean backslash=false;
+ // If last character is a word
+ boolean mot=false;
+
+ int crochet_liste=0;
+// boolean variable=false;
+ // If XLogo is running a program
+ boolean execution_lancee=Affichage.execution_lancee;
+ for(int i=0;i<st.length();i++){
+ char c=st.charAt(i);
+ if (c==' ') {
+ if (!espace&&buffer.length()!=0) {
+ if (backslash) buffer.append("\\e");
+ else {
+ buffer.append(c);
+ espace=true;
+ mot=false;
+ // variable=false;
+ }
+ backslash=false;
+ }
+ }
+ else if(c=='\\'&&!backslash) {
+ espace=false;
+ backslash=true;
+ }
+ else if(c=='\"'){
+ if (espace&&crochet_liste<=0){
+ mot=true;
+ }
+ buffer.append(c);
+ espace=false;
+ backslash=false;
+ }
+ else if (c==':'){
+ /* if (espace&&crochet_liste<=0){
+ variable=true;
+ }*/
+ buffer.append(c);
+ espace=false;
+ backslash=false;
+ }
+ else if (c=='['||c==']'||c=='('||c==')'){
+ //Modifications apportées
+ if (backslash) {
+ buffer.append("\\"+c);
+ backslash=false;
+ }
+ else {
+ if (c=='[') crochet_liste++;
+ else if (c==']') crochet_liste--;
+ if (espace||buffer.length()==0) {buffer.append(c+" ");espace=true;}
+ else {
+ buffer.append(" "+c+" ");
+ mot=false;
+ espace=true;
+ }
+ }
+ }
+ else if (c=='+'||c=='-'||c=='*'||c=='/'||c=='='||c=='<'||c=='>'||c=='&'||c=='|'){
+ //System.out.println(mot+" "+espace);
+ // à modifier (test + fin)
+ if (mot||crochet_liste>0) {
+ buffer.append(c);
+ if (espace) espace=false;
+ }
+ else {
+ String op=String.valueOf(c);
+ // Looking for operator <= or >=
+ if (c=='<'||c=='>'){
+ if (i+1<st.length()){
+ if (st.charAt(i+1)=='='){
+ op+="=";
+ i++;
+ }
+ }
+ }
+ if (espace) buffer.append(op+" ");
+ else {
+ espace=true;
+ if (buffer.length()!=0) buffer.append(" "+op+" ");
+ // If buffer is empty no white space before
+ else buffer.append(op+" ");
+ }
+ }
+ }
+ else{
+ if (backslash){
+ if (c=='n') buffer.append("\\n");
+ else if (c=='\\') buffer.append("\\\\");
+ else if (c=='v'&& execution_lancee) buffer.append("\"");
+ else if(c=='e'&& execution_lancee) buffer.append("\\e");
+ else if (c=='#') buffer.append("\\#");
+ else if (c=='l'&&execution_lancee) buffer.append("\\l");
+ else {
+ buffer.append(c);
+ }
+ }
+ else {
+ buffer.append(c);
+ }
+ backslash=false;
+ espace=false;
+ }
+ }
+// System.out.println(buffer);
+ // Remove the space when the user write only "*" or "+" in the command line
+ //if (buffer.length()>0&&buffer.charAt(0)==' ') buffer.deleteCharAt(0);
+ return (buffer);
+ }
+
+
+
+ public static String specialCharacterXML(String st){
+ st=st.replaceAll("&","&amp;");
+ st=st.replaceAll("<","&lt;");
+ st=st.replaceAll("\"","&quot;");
+ st=st.replaceAll(">","&gt;");
+ st=st.replaceAll("'","&apos;");
+
+ return st;
+ }
+ public static String readLogoFile(String path) throws IOException{ // ADAPT READ LOGO FILE
+ String txt="";
+ // The old format before XLogo 0.9.23 is no longer supported from version 0.9.30
+ try{
+ // New format for XLogo >=0.923
+ // Encoded with UTF-8
+ StringBuffer sb=new StringBuffer();
+ FileInputStream fr = new FileInputStream(path);
+ InputStreamReader isr = new InputStreamReader(fr, "UTF8");
+ BufferedReader brd=new BufferedReader(isr);
+ while (brd.ready()){
+ sb.append(brd.readLine());
+ sb.append("\n");
+ }
+ txt=new String(sb);
+ }
+ catch(FileNotFoundException e1){
+ // tentative fichier réseau
+ try{
+ URL url =new java.net.URL(path);
+ StringBuffer sb=new StringBuffer();
+ java.io.InputStream fr = url.openStream();
+ InputStreamReader isr = new InputStreamReader(fr, "UTF8");
+ BufferedReader brd=new BufferedReader(isr);
+ while (brd.ready()){
+ String st=brd.readLine();
+ sb.append(st);
+ sb.append("\n");
+ }
+ txt=new String(sb);
+ }
+ catch( java.net.MalformedURLException e){
+ System.out.println("File not found: "+path.toString());
+ }
+ }
+ catch(Exception e){e.printStackTrace();}
+ if (txt.startsWith("# "+Logo.messages.getString("mainCommand"))){
+ int id=txt.indexOf("\n");
+ if (id!=-1){
+ WSManager.getUserConfig().setMainCommand(txt.substring(("# "+Logo.messages.getString("mainCommand")).length(),id).trim());
+ txt=txt.substring(id+1);
+ }
+ };
+ return txt;
+ }
+
+ /**
+ * Store a string to a logo file path, UTF9 encoding,
+ * Write the main command to the head of the file with a #
+ * @param path
+ * @param txt
+ * @throws IOException
+ */
+ public static void writeLogoFile(String path,String txt) throws IOException{ // ADAPT write logo file
+ try{
+ if (!WSManager.getUserConfig().getMainCommand().trim().equals("")) {
+ String heading="# "+Logo.messages.getString("mainCommand")+" "+WSManager.getUserConfig().getMainCommand()+"\n";
+ txt=heading+txt;
+ }
+ FileOutputStream f = new FileOutputStream(path);
+ BufferedOutputStream b = new BufferedOutputStream(f);
+ OutputStreamWriter osw = new OutputStreamWriter(b, "UTF8");
+ osw.write(txt);
+ osw.close();
+ b.close();
+ f.close();
+
+ }
+ catch(FileNotFoundException e1){e1.printStackTrace();}
+ }
+ public static boolean fileExists(String name){
+ File f=new File(name);
+ return f.exists();
+ }
+
+ /**
+ * @param name
+ * @return
+ * @author Marko Zivkovic
+ */
+ public static boolean isFile(String path){
+ File f = new File(path);
+ return f.isFile();
+ }
+ /**
+ * @param path
+ * @return
+ * @author Marko Zivkovic
+ */
+ public static boolean isDirectory(String path){
+ File f = new File(path);
+ return f.isDirectory();
+ }
+
+ /**
+ * Implementation inspired by "JAVA ist auch eine Insel" - Christian Ullenboom, Galileo Computing
+ * <p> If destination exists, it will be replaced
+ * @param src
+ * @param dest
+ * @throws IOException If there is a problem with either src or dest
+ * @author Marko Zivkovic
+ */
+ public static void copyFile(String src, String dest) throws IOException
+ {
+ copyFile(new File(src), new File(dest));
+ }
+ /**
+ * Implementation inspired by "JAVA ist auch eine Insel" - Christian Ullenboom, Galileo Computing
+ * <p> If destination exists, it will be replaced
+ * @param src
+ * @param dest
+ * @throws IOException If there is a problem with either src or dest
+ * @author Marko Zivkovic
+ */
+ public static void copyFile(File src, File dest) throws IOException
+ {
+ FileInputStream fis = null;
+ FileOutputStream fos = null;
+
+ try
+ {
+ fis = new FileInputStream(src);
+ fos = new FileOutputStream(dest);
+ byte[] buffer = new byte[0xFFFF];
+ for (int len; (len = fis.read(buffer)) != -1;)
+ {
+ fos.write(buffer, 0, len);
+ }
+ }catch (IOException e) {
+ throw e;
+ }
+ finally {
+ if (fis != null)
+ try { fis.close(); } catch (IOException e) {}
+ if (fos != null)
+ try { fos.close(); } catch (IOException e) {}
+ }
+ }
+
+ /**
+ * First copy file to dest and then delete file.
+ * @param file
+ * @param dest
+ * @throws IOException If there is a problem with either file or dest
+ * @author Marko Zivkovic
+ */
+ public static void moveFile(String file, String dest) throws IOException
+ {
+ moveFile(new File(file), new File(dest));
+ }
+
+ /**
+ * First copy file to dest and then delete file.
+ * @param file
+ * @param dest
+ * @throws IOException If there is a problem with either file or dest
+ * @author Marko Zivkovic
+ */
+ public static void moveFile(File file, File dest) throws IOException
+ {
+ copyFile(file, dest);
+ file.delete();
+ }
+
+
+ public static String primitiveName(String generic){
+ Language lang = WSManager.getInstance().getWorkspaceConfigInstance().getLanguage();
+ Locale locale = lang.getLocale();
+ ResourceBundle prim = ResourceBundle.getBundle(
+ "primitives", locale);
+ String st = prim.getString(generic);
+ StringTokenizer str = new StringTokenizer(st);
+ while (str.hasMoreTokens()) {
+ st = str.nextToken();
+ }
+ return st;
+ }
+}
diff --git a/logo/src/xlogo/utils/WebPage.java b/logo/src/xlogo/utils/WebPage.java
new file mode 100644
index 0000000..56f1528
--- /dev/null
+++ b/logo/src/xlogo/utils/WebPage.java
@@ -0,0 +1,66 @@
+/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq
+ * Copyright (C) 2013 Marko Zivkovic
+ *
+ * Contact Information: marko88zivkovic at gmail dot com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version. This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details. You should have received a copy of the
+ * GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic
+ * during his Bachelor thesis at the computer science department of ETH Z�rich,
+ * in the year 2013 and/or during future work.
+ *
+ * It is a reengineered version of XLogo written by Lo�c Le Coq, published
+ * under the GPL License at http://xlogo.tuxfamily.org/
+ *
+ * Contents of this file were initially written by Lo�c Le Coq,
+ * modifications, extensions, refactorings might have been applied by Marko Zivkovic
+ */
+
+/**
+ * Title : XLogo
+ * Description : XLogo is an interpreter for the Logo
+ * programming language
+ * @author Loïc Le Coq
+ */
+package xlogo.utils;
+
+import javax.swing.event.*;
+import javax.swing.text.html.*;
+import javax.swing.JEditorPane;
+import javax.swing.event.HyperlinkListener;
+
+
+
+public class WebPage extends JEditorPane implements HyperlinkListener {
+ private static final long serialVersionUID = 1L;
+ public WebPage() {
+ super();
+ addHyperlinkListener(this);
+ }
+ public void hyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+ JEditorPane pane = (JEditorPane) e.getSource();
+ if (e instanceof HTMLFrameHyperlinkEvent) {
+ HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
+ HTMLDocument doc = (HTMLDocument)pane.getDocument();
+ doc.processHTMLFrameHyperlinkEvent(evt);
+ } else {
+ try {
+ pane.setPage(e.getURL());
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ }
+ }
+}
diff --git a/logo/src/xlogo/utils/WriteImage.java b/logo/src/xlogo/utils/WriteImage.java
new file mode 100644
index 0000000..13426f9
--- /dev/null
+++ b/logo/src/xlogo/utils/WriteImage.java
@@ -0,0 +1,122 @@
+/* XLogo4Schools - A Logo Interpreter specialized for use in schools, based on XLogo by Lo�c Le Coq
+ * Copyright (C) 2013 Marko Zivkovic
+ *
+ * Contact Information: marko88zivkovic at gmail dot com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version. This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details. You should have received a copy of the
+ * GNU General Public License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ *
+ * This Java source code belongs to XLogo4Schools, written by Marko Zivkovic
+ * during his Bachelor thesis at the computer science department of ETH Z�rich,
+ * in the year 2013 and/or during future work.
+ *
+ * It is a reengineered version of XLogo written by Lo�c Le Coq, published
+ * under the GPL License at http://xlogo.tuxfamily.org/
+ *
+ * Contents of this file were initially written by Lo�c Le Coq,
+ * modifications, extensions, refactorings might have been applied by Marko Zivkovic
+ */
+
+package xlogo.utils;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import xlogo.Logo;
+import xlogo.storage.WSManager;
+
+import java.awt.image.BufferedImage;
+import java.awt.Dimension;
+
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JProgressBar;
+import javax.swing.JDialog;
+
+public class WriteImage extends Thread{
+ private BufferedImage image;
+ private JFrame owner;
+ private String path;
+ public WriteImage(JFrame owner,BufferedImage image){
+ this.image=image;
+ this.owner=owner;
+ }
+ public void setImage(BufferedImage img){
+ image=img;
+ }
+ public int chooseFile(){
+ JFileChooser jf = new JFileChooser();
+ String[] ext={".jpg",".png"};
+ jf.addChoosableFileFilter(new ExtensionFichier(Logo.messages.getString("imagefile"),
+ ext ));
+ int retval = jf.showDialog(owner, Logo.messages.getString("menu.file.save"));
+ // Si l'utilisateur appuie sur enregistrer du JFileChooser
+ if (retval == JFileChooser.APPROVE_OPTION) {
+ // On rajoute l'extension convenable au fichier
+ path=jf.getSelectedFile().getPath();
+ String copie_path=path.toLowerCase(); //
+ if (!copie_path.endsWith(".jpg") && !copie_path.endsWith(".png")) {
+ String st = jf.getFileFilter().getDescription().toLowerCase();
+ if (st.endsWith("jpg)"))
+ path += ".jpg";
+ else if (st.endsWith("png)"))
+ path += ".png";
+ else
+ path += ".jpg";
+ }
+ }
+ return retval;
+ }
+
+ public void run(){
+
+ ProgressDialog progress=new ProgressDialog(owner);
+
+
+ Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
+ // On écrit le fichier
+ try {
+ if (path.endsWith(".jpg")) {
+ File f = new File(path);
+ ImageIO.write(image, "jpg", f);
+ }
+ else if (path.endsWith(".png")) {
+ File f = new File(path);
+ ImageIO.write(image, "png", f);
+ }
+ }
+ catch (IOException ex) {System.out.println(ex.toString());}
+ progress.dispose();
+ }
+ private class ProgressDialog extends JDialog{
+
+ private static final long serialVersionUID = 1L;
+ private JProgressBar prog=new JProgressBar();
+ ProgressDialog(JFrame owner){
+ super(owner);
+ initGui();
+ }
+ private void initGui(){
+ setFont(WSManager.getWorkspaceConfig().getFont());
+ setTitle(Logo.messages.getString("titredialogue2"));
+ prog.setIndeterminate(true);
+ java.awt.FontMetrics fm = owner.getGraphics()
+ .getFontMetrics(WSManager.getWorkspaceConfig().getFont());
+ int width = fm.stringWidth(Logo.messages.getString("titredialogue2"));
+ setSize(new Dimension(width+150,100));
+ getContentPane().add(prog);
+ setVisible(true);
+ }
+ }
+} \ No newline at end of file
diff --git a/logo/src/xlogo/utils/animation.png b/logo/src/xlogo/utils/animation.png
new file mode 100644
index 0000000..ec96348
--- /dev/null
+++ b/logo/src/xlogo/utils/animation.png
Binary files differ
diff --git a/logo/src/xlogo/utils/background.png b/logo/src/xlogo/utils/background.png
new file mode 100644
index 0000000..fa16b1b
--- /dev/null
+++ b/logo/src/xlogo/utils/background.png
Binary files differ
diff --git a/logo/src/xlogo/utils/chercher.png b/logo/src/xlogo/utils/chercher.png
new file mode 100644
index 0000000..f3d0e70
--- /dev/null
+++ b/logo/src/xlogo/utils/chercher.png
Binary files differ
diff --git a/logo/src/xlogo/utils/close_icon.png b/logo/src/xlogo/utils/close_icon.png
new file mode 100644
index 0000000..003e5af
--- /dev/null
+++ b/logo/src/xlogo/utils/close_icon.png
Binary files differ
diff --git a/logo/src/xlogo/utils/down_arrow.png b/logo/src/xlogo/utils/down_arrow.png
new file mode 100644
index 0000000..4cfbf80
--- /dev/null
+++ b/logo/src/xlogo/utils/down_arrow.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau0.png b/logo/src/xlogo/utils/drapeau0.png
new file mode 100644
index 0000000..1b03ba5
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau0.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau1.png b/logo/src/xlogo/utils/drapeau1.png
new file mode 100644
index 0000000..f7c5c02
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau1.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau10.png b/logo/src/xlogo/utils/drapeau10.png
new file mode 100644
index 0000000..41cfe91
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau10.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau11.png b/logo/src/xlogo/utils/drapeau11.png
new file mode 100644
index 0000000..0d8ceab
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau11.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau12.png b/logo/src/xlogo/utils/drapeau12.png
new file mode 100644
index 0000000..bcddaf4
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau12.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau13.png b/logo/src/xlogo/utils/drapeau13.png
new file mode 100644
index 0000000..2b8e820
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau13.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau2.png b/logo/src/xlogo/utils/drapeau2.png
new file mode 100644
index 0000000..22af90c
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau2.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau3.png b/logo/src/xlogo/utils/drapeau3.png
new file mode 100644
index 0000000..1444d86
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau3.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau4.png b/logo/src/xlogo/utils/drapeau4.png
new file mode 100644
index 0000000..e16dcb1
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau4.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau5.png b/logo/src/xlogo/utils/drapeau5.png
new file mode 100644
index 0000000..31378fd
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau5.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau6.png b/logo/src/xlogo/utils/drapeau6.png
new file mode 100644
index 0000000..68d1cbb
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau6.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau7.png b/logo/src/xlogo/utils/drapeau7.png
new file mode 100644
index 0000000..9f9f9b1
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau7.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau8.png b/logo/src/xlogo/utils/drapeau8.png
new file mode 100644
index 0000000..1a5a07c
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau8.png
Binary files differ
diff --git a/logo/src/xlogo/utils/drapeau9.png b/logo/src/xlogo/utils/drapeau9.png
new file mode 100644
index 0000000..81001a3
--- /dev/null
+++ b/logo/src/xlogo/utils/drapeau9.png
Binary files differ
diff --git a/logo/src/xlogo/utils/editcopy.png b/logo/src/xlogo/utils/editcopy.png
new file mode 100644
index 0000000..28b5162
--- /dev/null
+++ b/logo/src/xlogo/utils/editcopy.png
Binary files differ
diff --git a/logo/src/xlogo/utils/editcut.png b/logo/src/xlogo/utils/editcut.png
new file mode 100644
index 0000000..275571d
--- /dev/null
+++ b/logo/src/xlogo/utils/editcut.png
Binary files differ
diff --git a/logo/src/xlogo/utils/editpaste.png b/logo/src/xlogo/utils/editpaste.png
new file mode 100644
index 0000000..42c2122
--- /dev/null
+++ b/logo/src/xlogo/utils/editpaste.png
Binary files differ
diff --git a/logo/src/xlogo/utils/error.png b/logo/src/xlogo/utils/error.png
new file mode 100644
index 0000000..3dd3b55
--- /dev/null
+++ b/logo/src/xlogo/utils/error.png
Binary files differ
diff --git a/logo/src/xlogo/utils/fileprint.png b/logo/src/xlogo/utils/fileprint.png
new file mode 100644
index 0000000..669b738
--- /dev/null
+++ b/logo/src/xlogo/utils/fileprint.png
Binary files differ
diff --git a/logo/src/xlogo/utils/fog.png b/logo/src/xlogo/utils/fog.png
new file mode 100644
index 0000000..8cd7bfd
--- /dev/null
+++ b/logo/src/xlogo/utils/fog.png
Binary files differ
diff --git a/logo/src/xlogo/utils/gnu_gpl.png b/logo/src/xlogo/utils/gnu_gpl.png
new file mode 100644
index 0000000..8ac8564
--- /dev/null
+++ b/logo/src/xlogo/utils/gnu_gpl.png
Binary files differ
diff --git a/logo/src/xlogo/utils/icone.png b/logo/src/xlogo/utils/icone.png
new file mode 100644
index 0000000..20484b8
--- /dev/null
+++ b/logo/src/xlogo/utils/icone.png
Binary files differ
diff --git a/logo/src/xlogo/utils/info_icon.png b/logo/src/xlogo/utils/info_icon.png
new file mode 100644
index 0000000..4d7fe39
--- /dev/null
+++ b/logo/src/xlogo/utils/info_icon.png
Binary files differ
diff --git a/logo/src/xlogo/utils/light0.png b/logo/src/xlogo/utils/light0.png
new file mode 100644
index 0000000..2ce6bd6
--- /dev/null
+++ b/logo/src/xlogo/utils/light0.png
Binary files differ
diff --git a/logo/src/xlogo/utils/light1.png b/logo/src/xlogo/utils/light1.png
new file mode 100644
index 0000000..70e5149
--- /dev/null
+++ b/logo/src/xlogo/utils/light1.png
Binary files differ
diff --git a/logo/src/xlogo/utils/light2.png b/logo/src/xlogo/utils/light2.png
new file mode 100644
index 0000000..a5d6c42
--- /dev/null
+++ b/logo/src/xlogo/utils/light2.png
Binary files differ
diff --git a/logo/src/xlogo/utils/light3.png b/logo/src/xlogo/utils/light3.png
new file mode 100644
index 0000000..4dc827e
--- /dev/null
+++ b/logo/src/xlogo/utils/light3.png
Binary files differ
diff --git a/logo/src/xlogo/utils/menubtn.png b/logo/src/xlogo/utils/menubtn.png
new file mode 100644
index 0000000..ec6a2bf
--- /dev/null
+++ b/logo/src/xlogo/utils/menubtn.png
Binary files differ
diff --git a/logo/src/xlogo/utils/play.png b/logo/src/xlogo/utils/play.png
new file mode 100644
index 0000000..ea86208
--- /dev/null
+++ b/logo/src/xlogo/utils/play.png
Binary files differ
diff --git a/logo/src/xlogo/utils/preview0.png b/logo/src/xlogo/utils/preview0.png
new file mode 100644
index 0000000..4e428f5
--- /dev/null
+++ b/logo/src/xlogo/utils/preview0.png
Binary files differ
diff --git a/logo/src/xlogo/utils/preview1.png b/logo/src/xlogo/utils/preview1.png
new file mode 100644
index 0000000..632ffa7
--- /dev/null
+++ b/logo/src/xlogo/utils/preview1.png
Binary files differ
diff --git a/logo/src/xlogo/utils/preview2.png b/logo/src/xlogo/utils/preview2.png
new file mode 100644
index 0000000..69468cf
--- /dev/null
+++ b/logo/src/xlogo/utils/preview2.png
Binary files differ
diff --git a/logo/src/xlogo/utils/preview3.png b/logo/src/xlogo/utils/preview3.png
new file mode 100644
index 0000000..5b34a32
--- /dev/null
+++ b/logo/src/xlogo/utils/preview3.png
Binary files differ
diff --git a/logo/src/xlogo/utils/preview4.png b/logo/src/xlogo/utils/preview4.png
new file mode 100644
index 0000000..1173235
--- /dev/null
+++ b/logo/src/xlogo/utils/preview4.png
Binary files differ
diff --git a/logo/src/xlogo/utils/preview5.png b/logo/src/xlogo/utils/preview5.png
new file mode 100644
index 0000000..b6f276a
--- /dev/null
+++ b/logo/src/xlogo/utils/preview5.png
Binary files differ
diff --git a/logo/src/xlogo/utils/preview6.png b/logo/src/xlogo/utils/preview6.png
new file mode 100644
index 0000000..d7d1d2c
--- /dev/null
+++ b/logo/src/xlogo/utils/preview6.png
Binary files differ
diff --git a/logo/src/xlogo/utils/quit.png b/logo/src/xlogo/utils/quit.png
new file mode 100644
index 0000000..54be95d
--- /dev/null
+++ b/logo/src/xlogo/utils/quit.png
Binary files differ
diff --git a/logo/src/xlogo/utils/redo.png b/logo/src/xlogo/utils/redo.png
new file mode 100644
index 0000000..4766577
--- /dev/null
+++ b/logo/src/xlogo/utils/redo.png
Binary files differ
diff --git a/logo/src/xlogo/utils/remove_256.png b/logo/src/xlogo/utils/remove_256.png
new file mode 100644
index 0000000..51e436d
--- /dev/null
+++ b/logo/src/xlogo/utils/remove_256.png
Binary files differ
diff --git a/logo/src/xlogo/utils/screenshot.png b/logo/src/xlogo/utils/screenshot.png
new file mode 100644
index 0000000..792558e
--- /dev/null
+++ b/logo/src/xlogo/utils/screenshot.png
Binary files differ
diff --git a/logo/src/xlogo/utils/stop.png b/logo/src/xlogo/utils/stop.png
new file mode 100644
index 0000000..0c1a0a9
--- /dev/null
+++ b/logo/src/xlogo/utils/stop.png
Binary files differ
diff --git a/logo/src/xlogo/utils/tortue0.png b/logo/src/xlogo/utils/tortue0.png
new file mode 100644
index 0000000..ba7057b
--- /dev/null
+++ b/logo/src/xlogo/utils/tortue0.png
Binary files differ
diff --git a/logo/src/xlogo/utils/tortue1.png b/logo/src/xlogo/utils/tortue1.png
new file mode 100644
index 0000000..dd97517
--- /dev/null
+++ b/logo/src/xlogo/utils/tortue1.png
Binary files differ
diff --git a/logo/src/xlogo/utils/tortue2.png b/logo/src/xlogo/utils/tortue2.png
new file mode 100644
index 0000000..5ba638f
--- /dev/null
+++ b/logo/src/xlogo/utils/tortue2.png
Binary files differ
diff --git a/logo/src/xlogo/utils/tortue3.png b/logo/src/xlogo/utils/tortue3.png
new file mode 100644
index 0000000..1234947
--- /dev/null
+++ b/logo/src/xlogo/utils/tortue3.png
Binary files differ
diff --git a/logo/src/xlogo/utils/tortue4.png b/logo/src/xlogo/utils/tortue4.png
new file mode 100644
index 0000000..499fbef
--- /dev/null
+++ b/logo/src/xlogo/utils/tortue4.png
Binary files differ
diff --git a/logo/src/xlogo/utils/tortue5.png b/logo/src/xlogo/utils/tortue5.png
new file mode 100644
index 0000000..bf622f2
--- /dev/null
+++ b/logo/src/xlogo/utils/tortue5.png
Binary files differ
diff --git a/logo/src/xlogo/utils/tortue6.png b/logo/src/xlogo/utils/tortue6.png
new file mode 100644
index 0000000..2be5e71
--- /dev/null
+++ b/logo/src/xlogo/utils/tortue6.png
Binary files differ
diff --git a/logo/src/xlogo/utils/undo.png b/logo/src/xlogo/utils/undo.png
new file mode 100644
index 0000000..e7bc8ec
--- /dev/null
+++ b/logo/src/xlogo/utils/undo.png
Binary files differ
diff --git a/logo/src/xlogo/utils/up_arrow.png b/logo/src/xlogo/utils/up_arrow.png
new file mode 100644
index 0000000..06d5aee
--- /dev/null
+++ b/logo/src/xlogo/utils/up_arrow.png
Binary files differ
diff --git a/logo/src/xlogo/utils/zoomin.png b/logo/src/xlogo/utils/zoomin.png
new file mode 100644
index 0000000..c896f8f
--- /dev/null
+++ b/logo/src/xlogo/utils/zoomin.png
Binary files differ
diff --git a/logo/src/xlogo/utils/zoomout.png b/logo/src/xlogo/utils/zoomout.png
new file mode 100644
index 0000000..a3da47d
--- /dev/null
+++ b/logo/src/xlogo/utils/zoomout.png
Binary files differ