mycolorpickerline.mycolors.getSize().width)
+ x = mycolorpickerline.mycolors.getSize().width;
+ if (x < 0)
+ x = 0;
+ if (y > mycolorpickerline.mycolors.getSize().height)
+ y = mycolorpickerline.mycolors.getSize().height;
+ if (y < 0)
+ y = 0;
+
+ Global.setParameter("prefs.colorbackgroundx", x);
+ Global.setParameter("prefs.colorbackgroundy", y);
+
+ x = x * Pal.getSize().width
+ / mycolorpickerline.mycolors.getSize().width;
+ y = y * Pal.getSize().height
+ / mycolorpickerline.mycolors.getSize().height;
+
+ final Color mycolor = Pal.getColorAt(x, y);
+ if (mycolor != null) {
+ Global.setParameter("prefs.colorbackground", mycolor);
+ mycolorpickerline.mycolors.repaint();
+ }
+
+ }
+
+ public void mouseReleased(final MouseEvent e) {
+ xx = -1;
+ yy = -1;
+ }
+
+ public void mouseEntered(final MouseEvent e) {
+
+ }
+
+ public void mouseExited(final MouseEvent e) {
+ }
+
+ public void mouseDragged(final MouseEvent e) {
+ mousePressed(e);
+ }
+
+ public void mouseMoved(final MouseEvent e) {
+
+ }
+
+}
diff --git a/eric/JGlobalPreferencesCursor.java b/eric/JGlobalPreferencesCursor.java
new file mode 100644
index 0000000..795311c
--- /dev/null
+++ b/eric/JGlobalPreferencesCursor.java
@@ -0,0 +1,125 @@
+/*
+
+Copyright 2006 Eric Hakenholz
+
+This file is part of C.a.R. software.
+
+ C.a.R. is a 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, version 3 of the License.
+
+ C.a.R. 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, see .
+
+ */
+
+
+ package eric;
+
+import java.awt.Color;
+import java.awt.Font;
+
+import javax.swing.BoxLayout;
+import javax.swing.JLabel;
+import eric.JEricPanel;
+import javax.swing.JSlider;
+
+import rene.gui.Global;
+
+/**
+ *
+ * @author erichake
+ */
+public class JGlobalPreferencesCursor extends JEricPanel {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ JLabel mylabel, myval;
+ public JSlider mycursor;
+ String myP, mytxt;
+ int PW = 300;// standard palette width
+ boolean palmember = false;
+
+ /** Creates a new instance of JCursor */
+ @Override
+ public void paintComponent(final java.awt.Graphics g) {
+ super.paintComponent(g);
+ }
+
+ // JCursor constructor for palette member :
+ public JGlobalPreferencesCursor(final String myparam, final String mytext,
+ final int min, final int max, int sel) {
+ // this(mytext,40,min,max,rene.gui.Global.getParameter(myparam,sel));
+ sel = Global.getParameter(myparam, sel);
+ myP = myparam;
+ palmember = true;
+ final int lblwidth = 150;
+ final int valwidth = 20;
+ final int valheight = 27;
+ mytxt = mytext;
+ mycursor = new JSlider();
+ mylabel = new JLabel();
+ myval = new JLabel();
+ this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
+ // this.setAlignmentX(0);
+ mylabel.setText(" " + mytxt);
+ mylabel.setForeground(Color.DARK_GRAY);
+ mylabel.setFont(new Font(Global.GlobalFont, Font.PLAIN, 13));
+ mylabel.setSize(lblwidth, 27);
+ mylabel.setMaximumSize(new java.awt.Dimension(lblwidth, 27));
+ mylabel.setMinimumSize(new java.awt.Dimension(lblwidth, 27));
+ mylabel.setPreferredSize(new java.awt.Dimension(lblwidth, 27));
+ myval.setText(String.valueOf(sel));
+ myval.setForeground(Color.GRAY);
+ myval.setFont(new java.awt.Font(Global.GlobalFont, Font.BOLD, 13));
+ myval.setSize(valwidth, valheight);
+ myval.setMaximumSize(new java.awt.Dimension(valwidth, valheight));
+ myval.setMinimumSize(new java.awt.Dimension(valwidth, valheight));
+ myval.setPreferredSize(new java.awt.Dimension(valwidth, valheight));
+ mycursor.setFont(new java.awt.Font(Global.GlobalFont, 0, 11));
+ mycursor.setOpaque(false);
+ mycursor.setMajorTickSpacing(1);
+ mycursor.setMaximum(max);
+ mycursor.setMinimum(min);
+ mycursor.setMinorTickSpacing(1);
+ mycursor.setPaintLabels(false);
+ mycursor.setPaintTicks(false);
+ mycursor.setSnapToTicks(true);
+ mycursor.setValue(sel);
+ mycursor.setAlignmentX(0.0F);
+ mycursor.setMaximumSize(new java.awt.Dimension(
+ PW - lblwidth - valwidth, valheight));
+ mycursor.setMinimumSize(new java.awt.Dimension(
+ PW - lblwidth - valwidth, valheight));
+ mycursor.setPreferredSize(new java.awt.Dimension(PW - lblwidth
+ - valwidth, valheight));
+ mycursor.setSize(new java.awt.Dimension(PW - lblwidth - valwidth,
+ valwidth));
+
+ mycursor.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(final javax.swing.event.ChangeEvent evt) {
+ final JSlider myc = (JSlider) evt.getSource();
+ final int mysel = myc.getValue();
+ rene.gui.Global.setParameter(myP, mysel);
+
+ myval.setText(String.valueOf(mysel));
+ }
+ });
+
+ this.add(mylabel);
+ this.add(mycursor);
+ this.add(myval);
+ this.setOpaque(false);
+ this.setMaximumSize(new java.awt.Dimension(PW, 27));
+ this.setMinimumSize(new java.awt.Dimension(PW, 27));
+ this.setPreferredSize(new java.awt.Dimension(PW, 27));
+ this.setSize(PW, 27);
+ }
+
+}
diff --git a/eric/JGlobalPreferencesDlog.form b/eric/JGlobalPreferencesDlog.form
new file mode 100644
index 0000000..d4e912c
--- /dev/null
+++ b/eric/JGlobalPreferencesDlog.form
@@ -0,0 +1,190 @@
+
+
+
diff --git a/eric/JGlobalPreferencesDlog.java b/eric/JGlobalPreferencesDlog.java
new file mode 100644
index 0000000..acf8ede
--- /dev/null
+++ b/eric/JGlobalPreferencesDlog.java
@@ -0,0 +1,246 @@
+/*
+
+Copyright 2006 Eric Hakenholz
+
+This file is part of C.a.R. software.
+
+ C.a.R. is a 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, version 3 of the License.
+
+ C.a.R. 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, see .
+
+ */
+
+
+ package eric;
+
+import java.awt.Dimension;
+import java.awt.event.ItemEvent;
+
+import javax.swing.JComponent;
+import eric.JEricPanel;
+
+import rene.gui.Global;
+
+/**
+ *
+ * @author erichake
+ */
+public class JGlobalPreferencesDlog extends javax.swing.JFrame {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ /** Creates new form JGlobalPreferencesDlog */
+ public JGlobalPreferencesDlog() {
+ initComponents();
+ tabs.setTitleAt(0, Loc("sizes"));
+ tabs.setTitleAt(1, Loc("colors"));
+ tabs.setTitleAt(2, Loc("others"));
+ undock.setText(Loc("others.undock"));
+ JGlobalPreferences.savePreferences();
+ sizes.add(Vspacer(20));
+ sizes.add(new JGlobalPreferencesCursor("prefs.minpointsize",
+ Loc("sizes.minpointsize"), 1, 9, 3));
+ sizes.add(new JGlobalPreferencesCursor("prefs.minlinesize",
+ Loc("sizes.minlinesize"), 1, 9, 1));
+ sizes.add(new JGlobalPreferencesCursor("prefs.arrowsize",
+ Loc("sizes.arrowsize"), 3, 50, 15));
+ sizes.add(new JGlobalPreferencesCursor("prefs.minfontsize",
+ Loc("sizes.minfontsize"), 1, 64, 12));
+ sizes.add(Vspacer(20));
+ sizes.add(new JGlobalPreferencesCursor("prefs.digits.lengths",
+ Loc("sizes.digits.lengths"), 0, 12, 5));
+ sizes.add(new JGlobalPreferencesCursor("prefs.digits.edit",
+ Loc("sizes.digits.edit"), 0, 12, 5));
+ sizes.add(new JGlobalPreferencesCursor("prefs.digits.angles",
+ Loc("sizes.digits.angles"), 0, 12, 0));
+ colors.add(Vspacer(20));
+ colors.add(new JGlobalPreferencesColor());
+ undock.setSelected(Global.getParameter("prefs.undockpalette", false));
+ setVisible(true);
+ }
+
+ static private String Loc(final String s) {
+ return Global.Loc("menu.special.options."
+ + s);
+ }
+
+ static private JEricPanel Vspacer(final int h) {
+ final JEricPanel mysep = new JEricPanel();
+ mysep.setOpaque(false);
+ fixsize(mysep, new Dimension(1, h));
+ return mysep;
+ }
+
+ static private void fixsize(final JComponent cp, final Dimension d) {
+ cp.setMaximumSize(d);
+ cp.setMinimumSize(d);
+ cp.setPreferredSize(d);
+ cp.setSize(d);
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+ tabs = new javax.swing.JTabbedPane();
+ sizes = new javax.swing.JPanel();
+ colors = new javax.swing.JPanel();
+ other = new javax.swing.JPanel();
+ jPanel2 = new javax.swing.JPanel();
+ undock = new javax.swing.JCheckBox();
+ jPanel1 = new javax.swing.JPanel();
+ jPanel3 = new javax.swing.JPanel();
+ jButton2 = new javax.swing.JButton();
+
+ getContentPane().setLayout(
+ new javax.swing.BoxLayout(getContentPane(),
+ javax.swing.BoxLayout.Y_AXIS));
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle("Preferences");
+ setAlwaysOnTop(true);
+ setResizable(false);
+ addWindowListener(new java.awt.event.WindowAdapter() {
+ @Override
+ public void windowClosed(final java.awt.event.WindowEvent evt) {
+ formWindowClosed(evt);
+ }
+ });
+
+ tabs.setMaximumSize(new java.awt.Dimension(330, 360));
+ tabs.setMinimumSize(new java.awt.Dimension(330, 360));
+ tabs.setPreferredSize(new java.awt.Dimension(330, 360));
+ sizes.setLayout(new javax.swing.BoxLayout(sizes,
+ javax.swing.BoxLayout.Y_AXIS));
+
+ sizes.setOpaque(false);
+ tabs.addTab("Sizes", sizes);
+
+ colors.setLayout(new javax.swing.BoxLayout(colors,
+ javax.swing.BoxLayout.Y_AXIS));
+
+ colors.setOpaque(false);
+ tabs.addTab("Colors", colors);
+
+ other.setLayout(new javax.swing.BoxLayout(other,
+ javax.swing.BoxLayout.Y_AXIS));
+
+ other.setOpaque(false);
+ jPanel2.setEnabled(false);
+ jPanel2.setFocusable(false);
+ jPanel2.setMaximumSize(new java.awt.Dimension(32767, 20));
+ jPanel2.setMinimumSize(new java.awt.Dimension(10, 20));
+ jPanel2.setOpaque(false);
+ jPanel2.setPreferredSize(new java.awt.Dimension(10, 20));
+ other.add(jPanel2);
+
+ undock.setText("Accept undocked palette");
+ undock.setBorder(javax.swing.BorderFactory
+ .createEmptyBorder(0, 0, 0, 0));
+ undock.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ undock.setOpaque(false);
+ undock.addItemListener(new java.awt.event.ItemListener() {
+ public void itemStateChanged(final java.awt.event.ItemEvent evt) {
+ undockItemStateChanged(evt);
+ }
+ });
+
+ other.add(undock);
+
+ tabs.addTab("Other", other);
+
+ getContentPane().add(tabs);
+
+ jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1,
+ javax.swing.BoxLayout.X_AXIS));
+
+ jPanel1.setMaximumSize(new java.awt.Dimension(330, 40));
+ jPanel1.setMinimumSize(new java.awt.Dimension(330, 40));
+ jPanel1.setPreferredSize(new java.awt.Dimension(330, 40));
+ jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3,
+ javax.swing.BoxLayout.X_AXIS));
+
+ jPanel3.setMaximumSize(new java.awt.Dimension(247, 40));
+ jPanel3.setMinimumSize(new java.awt.Dimension(247, 40));
+ jPanel3.setOpaque(false);
+ jPanel3.setPreferredSize(new java.awt.Dimension(247, 40));
+ jPanel1.add(jPanel3);
+
+ jButton2.setText("close");
+ jButton2.setAlignmentX(0.5F);
+ jButton2.setFocusPainted(false);
+ jButton2.setFocusable(false);
+ jButton2.setMaximumSize(new java.awt.Dimension(75, 35));
+ jButton2.setMinimumSize(new java.awt.Dimension(75, 35));
+ jButton2.setPreferredSize(new java.awt.Dimension(75, 35));
+ jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
+ @Override
+ public void mouseClicked(final java.awt.event.MouseEvent evt) {
+ jButton2MouseClicked(evt);
+ }
+ });
+
+ jPanel1.add(jButton2);
+
+ getContentPane().add(jPanel1);
+
+ final java.awt.Dimension screenSize = java.awt.Toolkit
+ .getDefaultToolkit().getScreenSize();
+ setBounds((screenSize.width - 330) / 2, (screenSize.height - 422) / 2,
+ 330, 422);
+ }// //GEN-END:initComponents
+
+ private void undockItemStateChanged(final java.awt.event.ItemEvent evt) {// GEN-FIRST:event_undockItemStateChanged
+ Global.setParameter("prefs.undockpalette",
+ (evt.getStateChange() == ItemEvent.SELECTED));
+ }// GEN-LAST:event_undockItemStateChanged
+
+ private void formWindowClosed(final java.awt.event.WindowEvent evt) {// GEN-FIRST:event_formWindowClosed
+
+ JGlobalPreferences.initPreferences();// TODO add your handling code
+ // here:
+ }// GEN-LAST:event_formWindowClosed
+
+ private void jButton2MouseClicked(final java.awt.event.MouseEvent evt) {// GEN-FIRST:event_jButton2MouseClicked
+ dispose();// TODO add your handling code here:
+ }// GEN-LAST:event_jButton2MouseClicked
+
+ /**
+ * @param args
+ * the command line arguments
+ */
+ public static void main(final String args[]) {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new JGlobalPreferencesDlog().setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel colors;
+ private javax.swing.JButton jButton2;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel other;
+ private javax.swing.JPanel sizes;
+ private javax.swing.JTabbedPane tabs;
+ private javax.swing.JCheckBox undock;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/eric/JHelpPanel.java b/eric/JHelpPanel.java
new file mode 100644
index 0000000..734560c
--- /dev/null
+++ b/eric/JHelpPanel.java
@@ -0,0 +1,792 @@
+/*
+
+Copyright 2006 Eric Hakenholz
+
+This file is part of C.a.R. software.
+
+ C.a.R. is a 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, version 3 of the License.
+
+ C.a.R. 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, see .
+
+ */
+
+package eric;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.BorderFactory;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JEditorPane;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.metal.MetalComboBoxUI;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.html.StyleSheet;
+
+import rene.gui.Global;
+
+/**
+ * Info class. Reads a file "info.txt" or "de_info.txt" etc. that has the
+ * structure
+ *
+ * .subject1 substitute1 substitute2 ... .related subject subject ... Header ...
+ *
+ * .subject2 ...
+ *
+ * and displays the text, starting from header, searching for a subject or any
+ * of its substitutes. The headers of the related subjects are presented in a
+ * choice list. The user can switch to any of it.
+ *
+ * There is a history and a back button.
+ *
+ * Moroever, there is a search button, that displays the first subject
+ * containing a string and presents all other subjects containing the string in
+ * the choice list.
+ */
+public class JHelpPanel extends JEricPanel {
+
+ private static final long serialVersionUID = 1L;
+ MyJTextPane T;
+ public static String Subject = "start";
+ String Search = null;
+ // MyChoice2 L;
+ Vector Other = null;
+ Vector History = new Vector();
+ Vector Related;
+ JEricPanel north;
+ MyJTextSearch TSearch;
+
+ public JHelpPanel() {
+ T = new MyJTextPane(this);
+ final JScrollPane scrollPane = new JScrollPane(T);
+ scrollPane.setBorder(javax.swing.BorderFactory.createEmptyBorder());
+ setAlignmentX(0.0F);
+ setAlignmentY(0.0F);
+
+ setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
+ setFocusable(false);
+
+ north = new JEricPanel();
+ north.setLayout(new javax.swing.BoxLayout(north, javax.swing.BoxLayout.Y_AXIS));
+ north.setOpaque(false);
+ TSearch = new MyJTextSearch(this);
+ Subject = "start";
+ fill(true);
+ north.add(TSearch);
+ north.add(vmargin(2));
+
+ add(north);
+ add(scrollPane);
+ }
+
+ public void focusTxt() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ TSearch.JTF.requestFocus();
+ }
+ });
+ }
+
+ static JEricPanel margin(final int w) {
+ final JEricPanel mypan = new JEricPanel();
+ fixsize(mypan, w, 1);
+ mypan.setLayout(new javax.swing.BoxLayout(mypan, javax.swing.BoxLayout.X_AXIS));
+ mypan.setAlignmentX(0F);
+ mypan.setAlignmentY(0F);
+ mypan.setOpaque(false);
+ mypan.setFocusable(false);
+ return mypan;
+ }
+
+ static JEricPanel vmargin(final int h) {
+ final JEricPanel mypan = new JEricPanel();
+ fixsize(mypan, 1, h);
+ mypan.setLayout(new javax.swing.BoxLayout(mypan, javax.swing.BoxLayout.X_AXIS));
+ mypan.setAlignmentX(0F);
+ mypan.setAlignmentY(0F);
+ mypan.setOpaque(false);
+ mypan.setFocusable(false);
+ return mypan;
+ }
+
+ // Only called by LeftPanelContent init method :
+ public void fixPanelSize(final int w, final int h) {
+ fixsize(north, w, 24);
+ north.revalidate();
+ fixsize(TSearch, w, 24);
+ fixsize(TSearch.wholepanel, w - 20, 18);
+ }
+
+ public static void fixsize(final JComponent cp, final int w, final int h) {
+ final Dimension d = new Dimension(w, h);
+ cp.setMaximumSize(d);
+ cp.setMinimumSize(d);
+ cp.setPreferredSize(d);
+ cp.setSize(d);
+ }
+
+ public void clearSearchTxtField() {
+ TSearch.JTF.setText("");
+ }
+
+ public final void fill(final boolean WithTextFocus) {
+ final boolean vis = TSearch.ispopupvisible();
+ if (vis) {
+ TSearch.hidepopup();
+ }
+ TSearch.L = new MyJPopupMenu(this);
+ T.setText("");
+
+ String TXT = "";
+
+ boolean Found = false, Appending = false;
+ Related = null;
+ Other = new Vector();
+ String pair[] = null, lastpair[] = null;
+ String lang = Global.name("language", "");
+ Vector SearchResults = new Vector();
+ String SearchResult = "";
+ String FoundTopic = null;
+ boolean FirstRun = true, FoundHeader = false;
+
+ String Search1 = Search;
+ if (Search != null && Search.length() > 0) {
+ Search1 = Search.substring(0, 1).toUpperCase() + Search.substring(1);
+ }
+
+ read: while (true) {
+ try {
+ Global.name("codepage.help", "");
+ BufferedReader in = null;
+ try {
+ in = new BufferedReader(new InputStreamReader(
+ new FileInputStream(Global.getHomeDirectory() + "docs/" + lang + "info.txt"), "UTF8"));
+ } catch (final Exception ex) {
+ in = new BufferedReader(new InputStreamReader(
+ new FileInputStream(Global.getHomeDirectory() + "docs/" + lang + "info.txt")));
+ }
+
+ boolean newline = false;
+ newline: while (true) {
+ String s = in.readLine();
+ if (s == null) {
+ break newline;
+ }
+ if (s.startsWith("//")) {
+ continue;
+ }
+ s = clear(s);
+ if (!s.startsWith(".") && Search != null && (s.indexOf(Search) >= 0 || s.indexOf(Search1) >= 0)) {
+ if (lastpair != null && pair == null && !SearchResult.equals(lastpair[0])) {
+ SearchResults.addElement(lastpair);
+
+ SearchResult = lastpair[0];
+ if (FoundTopic == null) {
+ FoundTopic = lastpair[0];
+ }
+ }
+ }
+ interpret: while (true) {
+ if (!Appending && s.startsWith(".") && !s.startsWith(".related")) {
+ if (!Found) {
+ if (s.startsWith("." + Subject)) {
+ Found = true;
+ Appending = true;
+ continue newline;
+ }
+ final StringTokenizer t = new StringTokenizer(s);
+ while (t.hasMoreElements()) {
+ final String name = t.nextToken();
+ if (name.equals(Subject)) {
+ Found = true;
+ Appending = true;
+ continue newline;
+ }
+ }
+ }
+ pair = new String[2];
+ s = s.substring(1);
+ final int n = s.indexOf(' ');
+ if (n > 0) {
+ s = s.substring(0, n);
+ }
+ pair[0] = s;
+ continue newline;
+ }
+ if (Appending) {
+ if (s.startsWith(".related")) {
+ s = s.substring(".related".length());
+ Related = new Vector();
+ final StringTokenizer t = new StringTokenizer(s);
+ while (t.hasMoreElements()) {
+ Related.addElement(t.nextToken());
+ }
+ continue newline;
+ }
+ if (s.startsWith(".")) {
+ Appending = false;
+ continue interpret;
+ }
+ if (s.trim().equals("")) {
+ if (!newline) {
+ // T.append("
");
+ TXT += "
";
+ }
+ newline = true;
+ } else {
+ newline = false;
+ if (s.startsWith(" ")) {
+ TXT += "
";
+ // T.append("
");
+ }
+ // T.append(s+" ");
+ TXT += s + " ";
+ }
+ } else if (pair != null && !s.startsWith(".")) {
+ pair[1] = s;
+ Other.addElement(pair);
+ lastpair = pair;
+ pair = null;
+ if (Search != null && (s.indexOf(Search) >= 0 || s.indexOf(Search1) >= 0)) {
+ if (!SearchResult.equals(lastpair[0])) {
+ SearchResults.addElement(lastpair);
+ SearchResult = lastpair[0];
+ if (!FoundHeader) {
+ FoundTopic = lastpair[0];
+ }
+ FoundHeader = true;
+ }
+ }
+ }
+ continue newline;
+ }
+ }
+ // T.append("
");
+ TXT += "
";
+ in.close();
+ } catch (final Exception e) {
+ if (!lang.equals("")) {
+ lang = "";
+ continue read;
+ } else {
+ // V.appendLine(
+ // Global.name("help.error","Could not find the help file!"));
+ // T.append(Global.name("help.error",
+ // "Could not find the help file!"));
+ TXT += Global.name("help.error", "Could not find the help file!");
+ }
+ }
+ if (FoundTopic != null && FirstRun) {
+ Subject = FoundTopic;
+ SearchResults = new Vector();
+ SearchResult = "";
+ pair = null;
+ lastpair = null;
+ Found = false;
+ TXT = "";
+ // T.setText("");
+ // V.setText("");
+ FirstRun = false;
+ continue read;
+ } else {
+ break read;
+ }
+ }
+
+ // if (!Found)
+ // V.appendLine(Global.name("info.notfound","Topic not found!"));
+ if (!Found) {
+ // T.append(Global.name("info.notfound", "Topic not found!"));
+ TXT += Global.name("info.notfound", "Topic not found!");
+ }
+ if (Search != null) {
+ if (SearchResults.size() > 0) {
+ TSearch.L.addI(Global.name("info.searchresults"));
+ } else {
+ TSearch.L.addI(Global.name("info.noresults"));
+ }
+ } else {
+ TSearch.L.addI(Global.name("info.select"));
+ }
+ if (Search == null && Related != null) {
+ final Enumeration e = Related.elements();
+ while (e.hasMoreElements()) {
+ final String topic = (String) e.nextElement();
+ final Enumeration ev = Other.elements();
+ while (ev.hasMoreElements()) {
+ final String s[] = (String[]) ev.nextElement();
+ if (s[0].equals(topic)) {
+ TSearch.L.addI(s[1]);
+ break;
+ }
+ }
+ }
+ }
+
+ if (Search != null) {
+ final Enumeration e = SearchResults.elements();
+ while (e.hasMoreElements()) {
+ final String s[] = (String[]) e.nextElement();
+ TSearch.L.addI(s[1]);
+ }
+ }
+ T.setContent(TXT);
+ if (WithTextFocus) {
+ focusTxt();
+ }
+ T.setCaretPosition(0);
+ History.addElement(Subject);
+ TSearch.setCount();
+ if (vis) {
+ TSearch.showpopup();
+ }
+ }
+
+ public String clear(String s) {
+ s = s.replace('ß', ' ');
+ s = s.replaceAll("__", "");
+ return s;
+ }
+}
+
+class MyComboBoxUI extends MetalComboBoxUI {
+
+ public static ComponentUI createUI(final JComponent c) {
+ return new MyComboBoxUI();
+ }
+}
+
+class MyJTextSearch extends JEricPanel {
+
+ private static final long serialVersionUID = 1L;
+ JLabel cntLBL = new JLabel();
+ JTextField JTF;
+ JHelpPanel JP;
+ JButton popBTN, clearBTN;
+ JEricPanel txtpanel;
+ JEricPanel wholepanel;
+ MyJPopupMenu L;
+ String old = "";
+
+ @Override
+ public void paintComponent(final java.awt.Graphics g) {
+ super.paintComponent(g);
+ final ImageIcon OffImage = new ImageIcon(getClass().getResource("/eric/GUI/icons/themes/common/helpsearchback.png"));
+ final java.awt.Dimension d = this.getSize();
+ g.drawImage(OffImage.getImage(), 0, 0, d.width, d.height, this);
+ }
+
+ public MyJTextSearch(final JHelpPanel jp) {
+ super();
+ setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
+ setOpaque(false);
+ JP = jp;
+
+ L = new MyJPopupMenu(JP);
+
+ txtpanel = new JEricPanel();
+ txtpanel.setLayout(new javax.swing.BoxLayout(txtpanel, javax.swing.BoxLayout.X_AXIS));
+ txtpanel.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
+ txtpanel.setOpaque(true);
+ txtpanel.setBackground(Color.WHITE);
+ wholepanel = new JEricPanel();
+ wholepanel.setLayout(new javax.swing.BoxLayout(wholepanel, javax.swing.BoxLayout.X_AXIS));
+ wholepanel.setBorder(BorderFactory.createEmptyBorder());
+ wholepanel.setOpaque(false);
+ cntLBL.setOpaque(false);
+ cntLBL.setText("");
+ cntLBL.setFont(new Font("System", 0, 9));
+ cntLBL.setHorizontalAlignment(SwingConstants.CENTER);
+ cntLBL.setVerticalAlignment(SwingConstants.CENTER);
+ JHelpPanel.fixsize(cntLBL, 20, 18);
+
+ JTF = new JTextField();
+ JTF.setFont(new Font("System", 0, 11));
+ JTF.setForeground(new Color(50, 50, 50));
+ JTF.setBackground(new Color(255, 255, 255));
+ JTF.setBorder(BorderFactory.createEmptyBorder());
+ JTF.setMargin(new java.awt.Insets(0, 0, 1, 0));
+ JTF.addKeyListener(new KeyAdapter() {
+
+ @Override
+ public void keyReleased(final KeyEvent e) {
+ if (JTF.getText().equals("")) {
+ clearBTN.setVisible(false);
+ } else {
+ clearBTN.setVisible(true);
+ }
+ if ((e.getKeyCode() == KeyEvent.VK_ENTER) || (e.getKeyCode() == KeyEvent.VK_UP)) {
+ hidepopup();
+ } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
+ showpopup();
+ } else {
+ doSearch(JTF.getText());
+ }
+ }
+ });
+ // JTF.setFocusable(true);
+ JTF.addFocusListener(new FocusAdapter() {
+
+ @Override
+ public void focusGained(final FocusEvent e) {
+ JTF.selectAll();
+ }
+ });
+
+ final ImageIcon carimg = new ImageIcon(getClass().getResource("/eric/GUI/icons/themes/common/helpsearch1.gif"));
+ popBTN = new JButton(carimg);
+ popBTN.setBorder(BorderFactory.createEmptyBorder());
+ popBTN.setOpaque(true);
+ popBTN.setContentAreaFilled(true);
+ popBTN.setFocusable(false);
+ popBTN.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mousePressed(final MouseEvent e) {
+ showpopup();
+ }
+ });
+
+ final ImageIcon carimg2 = new ImageIcon(getClass().getResource("/eric/GUI/icons/themes/common/helpsearch2.png"));
+ final JButton backBTN = new JButton(carimg2);
+ backBTN.setBorder(BorderFactory.createEmptyBorder());
+ backBTN.setOpaque(false);
+ backBTN.setContentAreaFilled(false);
+ backBTN.setFocusable(false);
+ backBTN.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mousePressed(final MouseEvent e) {
+ final int n = JP.History.size();
+ if (n < 2) {
+ return;
+ }
+ JP.History.removeElementAt(n - 1);
+ JHelpPanel.Subject = (String) JP.History.elementAt(n - 2);
+ JP.History.removeElementAt(n - 2);
+ JP.fill(true);
+ }
+ });
+
+ final ImageIcon carimg3 = new ImageIcon(getClass().getResource("/eric/GUI/icons/themes/common/helpsearch3.gif"));
+ clearBTN = new JButton(carimg3);
+ clearBTN.setBorder(BorderFactory.createEmptyBorder());
+ clearBTN.setOpaque(true);
+ clearBTN.setContentAreaFilled(true);
+ clearBTN.setFocusable(false);
+ clearBTN.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mousePressed(final MouseEvent e) {
+ JTF.setText("");
+ clearBTN.setVisible(false);
+ doSearch("");
+ }
+ });
+ clearBTN.setVisible(false);
+ JHelpPanel.fixsize(popBTN, carimg.getIconWidth(), carimg.getIconHeight());
+ JHelpPanel.fixsize(clearBTN, carimg3.getIconWidth(), carimg3.getIconHeight());
+ txtpanel.add(cntLBL);
+ txtpanel.add(popBTN);
+ txtpanel.add(JHelpPanel.margin(3));
+ txtpanel.add(JTF);
+ txtpanel.add(clearBTN);
+ wholepanel.add(JHelpPanel.margin(5));
+ wholepanel.add(txtpanel);
+ wholepanel.add(JHelpPanel.margin(3));
+ wholepanel.add(backBTN);
+ this.add(JHelpPanel.vmargin(3));
+ this.add(wholepanel);
+ }
+
+ void showpopup() {
+ if (L.Count > 1) {
+ L.show(popBTN, 10, 20);
+ }
+ }
+
+ void hidepopup() {
+ L.setVisible(false);
+ }
+
+ boolean ispopupvisible() {
+ return L.isVisible();
+ }
+
+ void doSearch(final String s) {
+ if (s.equals("")) {
+ JP.Search = null;
+ } else {
+ JP.Search = s;
+ }
+ JHelpPanel.Subject = "start";
+ JP.fill(true);
+ JP.Search = null;
+ }
+
+ void setCount() {
+ if (L.Count > 1) {
+ cntLBL.setText("(" + (L.Count - 1) + ")");
+ } else {
+ cntLBL.setText("");
+ }
+ }
+}
+
+class MyJPopupMenuItem extends JMenuItem {
+
+ private static final long serialVersionUID = 1L;
+ String STR;
+ JHelpPanel JP;
+
+ public MyJPopupMenuItem(final JHelpPanel jp, final String s) {
+ super(s.replaceAll("", "").replace("
", ", "));
+ STR = s;
+ JP = jp;
+
+ setFont(new Font("System", 0, 11));
+ addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mousePressed(final MouseEvent arg0) {
+ JP.TSearch.L.setVisible(false);
+ JP.TSearch.JTF.setText("");
+ JP.TSearch.clearBTN.setVisible(false);
+ final String s = STR;
+ final Enumeration ev = JP.Other.elements();
+ while (ev.hasMoreElements()) {
+ final String p[] = (String[]) ev.nextElement();
+ if (p[1].equals(s)) {
+ JHelpPanel.Subject = p[0];
+ JP.fill(true);
+ break;
+ }
+ }
+ }
+ });
+ }
+}
+
+class MyJPopupMenu extends JPopupMenu {
+
+ private static final long serialVersionUID = 1L;
+ int Count = 0;
+ JHelpPanel JP;
+
+ public MyJPopupMenu(final JHelpPanel jp) {
+ super();
+ JP = jp;
+ setFont(new Font("System", 0, 11));
+ setFocusable(false);
+ }
+
+ public void addI(final String s) {
+ Count++;
+ add(new MyJPopupMenuItem(JP, s));
+ }
+}
+
+class MyJTextPane extends JEditorPane implements HyperlinkListener {
+
+ private static final long serialVersionUID = 1L;
+ String content;
+ HTMLEditorKit editorkit;
+ HTMLDocument doc;
+ JHelpPanel JP;
+
+ public MyJTextPane(final JHelpPanel jp) {
+ super();
+ JP = jp;
+ this.setContentType("text/html;");
+ editorkit = (HTMLEditorKit) getEditorKit();
+ doc = (HTMLDocument) getDocument();
+ final StyleSheet myStyleSheet = new StyleSheet();
+ myStyleSheet.addRule("body {color: #333333;font-family: Verdana, Arial, Helvetica, sans-serif;"
+ + "text-align: justify;font-size: 10px;background-color: #F1F3F9;}");
+ myStyleSheet.addRule("ul {text-align: left;list-style-type: disc;padding-left: 15px;list-style-position: outside;}");
+ myStyleSheet.addRule(".pfooter {text-align: center;font-size: 10px;padding-bottom: 5px;"
+ + "padding-top: 5px;background-color: #eaedf3;}");
+ myStyleSheet.addRule(".pfootertitle {font-weight: bold;text-align: center;font-size: 10px;padding-bottom: 5px;"
+ + "padding-top: 5px;background-color: #DBDDE3;}");
+ myStyleSheet.addRule("a {color: #0a9100;text-decoration: none;}");
+ myStyleSheet.addRule(".aanchor {color: #CC6633;}");
+ myStyleSheet.addRule(".centered {text-align: center;}");
+ myStyleSheet.addRule(".comment {text-align: center;font-size: 9px;font-style: oblique;font-weight: normal;}");
+ myStyleSheet.addRule(".comment2 {text-align: justify;font-size: 9px;font-style: oblique;font-weight: normal;}");
+ myStyleSheet.addRule(".ttle {color: #000000;font-family: Verdana, Arial, Helvetica, sans-serif;"
+ + "text-align: center;font-weight: bold;font-size: 11px;background-color: #DBDDE3;}");
+ myStyleSheet.addRule(".tab {border-width: 1px;border-color: #909090;border-style:solid;}");
+ myStyleSheet.addRule(".tds {border-width: 1px;border-color: #909090;border-style:solid;background-color: #DBDDE3;}");
+ myStyleSheet.addRule(".image {border-width: 1px;border-color: #909090;border-style:solid;background-color: #F1F3F9;}");
+ editorkit.setStyleSheet(myStyleSheet);
+ this.setEditable(false);
+ addHyperlinkListener(this);
+ }
+
+ void fixImagePath() {
+ final String SP = System.getProperty("file.separator");
+
+ // Check if there are external images (inside the docs folder of
+ // carmetal_config directory
+ Pattern p = Pattern.compile("(]*src=\")(images/)([^\"]+)(\"[^>]*>)", Pattern.CASE_INSENSITIVE);
+ Matcher m = p.matcher(content);
+ StringBuffer sb = new StringBuffer();
+
+ while (m.find()) {
+ String myst = "
" + m.group(1) + "file:///";
+ myst += Global.getHomeDirectory().replace("\\", "\\\\");
+ myst += "docs/images/".replace("/", SP).replace("\\", "\\\\");
+ myst += m.group(3).replace("/", SP).replace("\\", "\\\\");
+
+ // on windows, the img tag seems to need the width and height
+ // attribute :
+ final ImageIcon myimg = new ImageIcon(Global.getHomeDirectory() + "docs/images/" + m.group(3));
+ if (myimg != null) {
+ myst += "\" width=\"" + myimg.getIconWidth() + "\" height=\"" + myimg.getIconHeight() + "\"";
+ }
+
+ myst += m.group(4);
+ myst += "
";
+ m.appendReplacement(sb, myst);
+ }
+ m.appendTail(sb);
+ m.reset();
+ content = sb.toString();
+
+ // Check if there are internal images (inside the jar archive with root
+ // eric/GUI/icons/ :
+ p = Pattern.compile("(]*src=\")(#)([^\"]+)(\"[^>]*>)", Pattern.CASE_INSENSITIVE);
+ m = p.matcher(content);
+ sb = new StringBuffer();
+ while (m.find()) {
+ final URL myIMG = Global.getPath("eric/GUI/icons/" + m.group(3));
+ if (myIMG == null)
+ continue;
+ String myst = m.group(1);
+ myst += myIMG.toString();
+ myst += m.group(4);
+ m.appendReplacement(sb, myst);
+ }
+ m.appendTail(sb);
+ m.reset();
+ content = sb.toString();
+ }
+
+ void setTitle() {
+ if (content.equals("")) {
+ return;
+ }
+ content = content.replace("href=\"#", "class=\"aanchor\" href=\"#");
+ final URL myIMG = Global.getPath("eric/GUI/icons/palette/" + JHelpPanel.Subject + ".png");
+ final String mytitle = content.substring(0, content.indexOf("
"));
+ String tag = "";
+ if (myIMG == null) {
+ tag = "";
+ tag += "" + mytitle + " | ";
+ tag += "
";
+ } else {
+ tag = "";
+ tag += "" + mytitle + " | ";
+ tag += " | ";
+ tag += "
";
+ }
+ content = content.replaceFirst(mytitle, tag);
+ }
+
+ void setFooter() {
+ final Enumeration e = JP.Related.elements();
+ String tag = "";
+ while (e.hasMoreElements()) {
+ final String topic = (String) e.nextElement();
+ String topicTitle = "";
+ final Enumeration ev = JP.Other.elements();
+
+ while (ev.hasMoreElements()) {
+ final String s[] = (String[]) ev.nextElement();
+ if (s[0].equals(topic)) {
+ topicTitle = s[1];
+ break;
+ }
+ }
+
+ tag += "
";
+ }
+
+ if (!tag.equals("")) {
+ content += "";
+ content += "
";
+ content += tag;
+ content += "
";
+ }
+ }
+
+ void setContent(final String s) {
+ try {
+ content = s;
+ fixImagePath();
+ setTitle();
+ setFooter();
+ editorkit.insertHTML(doc, doc.getLength(), content, 0, 0, null);
+ } catch (final Exception ex) {
+ }
+ // JP.focusTxt();
+ }
+
+ @Override
+ public void hyperlinkUpdate(final HyperlinkEvent r) {
+ if (r.getEventType() == javax.swing.event.HyperlinkEvent.EventType.ACTIVATED) {
+ String lnk = "";
+ if (r.getDescription().startsWith("#")) {
+ lnk = r.getDescription().substring(1);
+ JHelpPanel.Subject = lnk;
+ JP.clearSearchTxtField();
+ JP.fill(true);
+ return;
+ } else {
+ lnk = r.getDescription();
+ if (!lnk.startsWith("http://")) {
+ lnk = "http://" + lnk;
+ }
+ JBrowserLauncher.openURL(lnk);
+ return;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/eric/JLicence.java b/eric/JLicence.java
new file mode 100644
index 0000000..77ec77b
--- /dev/null
+++ b/eric/JLicence.java
@@ -0,0 +1,185 @@
+/*
+
+Copyright 2006 Eric Hakenholz
+
+This file is part of C.a.R. software.
+
+ C.a.R. is a 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, version 3 of the License.
+
+ C.a.R. 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, see .
+
+ */
+
+
+ package eric;
+
+import eric.GUI.themes;
+import java.awt.Cursor;
+import javax.swing.JComponent;
+import rene.gui.Global;
+
+/**
+ *
+ * @author erichake
+ */
+public class JLicence extends javax.swing.JFrame {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ @Override
+ public void paint(final java.awt.Graphics g) {
+ super.paint(g);
+ final java.awt.Dimension d = this.getSize();
+ g.drawImage(themes.getImage("backcontrols.gif"), 0, 0, d.width,
+ d.height, this);
+ // super.paint(g);
+ mytxt.repaint();
+ mylink.repaint();
+ }
+
+ /** Creates new form JLicence */
+ public JLicence(JComponent jp) {
+ initComponents();
+ mytxt.setText(Global.Loc("licence.txt"));
+ mytxt.setOpaque(false);
+ mylink
+ .setText("http://www.gnu.org/licenses/gpl.txt");
+ mylink.setOpaque(false);
+ mylink.setCursor(new Cursor(Cursor.HAND_CURSOR));
+ this.setLocationRelativeTo(jp);
+ this.setVisible(true);
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ //
+ private void initComponents() {
+ jPanel2 = new javax.swing.JPanel();
+ jPanel1 = new javax.swing.JPanel();
+ mytxt = new javax.swing.JLabel();
+ mylink = new javax.swing.JLabel();
+ jPanel3 = new javax.swing.JPanel();
+
+ getContentPane().setLayout(
+ new javax.swing.BoxLayout(getContentPane(),
+ javax.swing.BoxLayout.Y_AXIS));
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ setTitle("Licence");
+ setResizable(false);
+ setUndecorated(true);
+ addMouseListener(new java.awt.event.MouseAdapter() {
+ @Override
+ public void mousePressed(final java.awt.event.MouseEvent evt) {
+ formMousePressed(evt);
+ }
+ });
+ addWindowListener(new java.awt.event.WindowAdapter() {
+ @Override
+ public void windowDeactivated(final java.awt.event.WindowEvent evt) {
+ formWindowDeactivated(evt);
+ }
+ });
+
+ jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2,
+ javax.swing.BoxLayout.X_AXIS));
+
+ jPanel2.setMaximumSize(new java.awt.Dimension(320, 10));
+ jPanel2.setMinimumSize(new java.awt.Dimension(320, 10));
+ jPanel2.setPreferredSize(new java.awt.Dimension(320, 10));
+ getContentPane().add(jPanel2);
+
+ jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1,
+ javax.swing.BoxLayout.Y_AXIS));
+
+ jPanel1.setOpaque(false);
+ mytxt.setBackground(new java.awt.Color(255, 255, 255));
+ mytxt.setFont(new java.awt.Font("Dialog", 0, 12));
+ mytxt.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ mytxt.setText("txt");
+ mytxt.setAlignmentX(0.5F);
+ mytxt.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+ mytxt.setMaximumSize(new java.awt.Dimension(300, 95));
+ mytxt.setMinimumSize(new java.awt.Dimension(300, 95));
+ mytxt.setPreferredSize(new java.awt.Dimension(300, 95));
+ mytxt.addMouseListener(new java.awt.event.MouseAdapter() {
+ @Override
+ public void mousePressed(final java.awt.event.MouseEvent evt) {
+ mytxtMousePressed(evt);
+ }
+ });
+
+ jPanel1.add(mytxt);
+
+ mylink.setBackground(new java.awt.Color(255, 255, 255));
+ mylink.setFont(new java.awt.Font("Dialog", 0, 12));
+ mylink.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ mylink.setText("coucou");
+ mylink.setAlignmentX(0.5F);
+ mylink.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+ mylink.setMaximumSize(new java.awt.Dimension(300, 40));
+ mylink.setMinimumSize(new java.awt.Dimension(300, 40));
+ mylink.setOpaque(true);
+ mylink.setPreferredSize(new java.awt.Dimension(300, 40));
+ mylink.addMouseListener(new java.awt.event.MouseAdapter() {
+ @Override
+ public void mousePressed(final java.awt.event.MouseEvent evt) {
+ mylinkMousePressed(evt);
+ }
+ });
+
+ jPanel1.add(mylink);
+
+ getContentPane().add(jPanel1);
+
+ jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3,
+ javax.swing.BoxLayout.X_AXIS));
+
+ jPanel3.setMaximumSize(new java.awt.Dimension(320, 10));
+ jPanel3.setMinimumSize(new java.awt.Dimension(320, 10));
+ jPanel3.setPreferredSize(new java.awt.Dimension(320, 10));
+ getContentPane().add(jPanel3);
+
+ pack();
+ }//
+
+ private void mylinkMousePressed(final java.awt.event.MouseEvent evt) {
+ JBrowserLauncher.openURL("http://www.gnu.org/licenses/gpl.txt");
+ this.dispose();// TODO add your handling code here:
+ }
+
+ private void formWindowDeactivated(final java.awt.event.WindowEvent evt) {
+ this.dispose();// TODO add your handling code here:
+ }
+
+ private void formMousePressed(final java.awt.event.MouseEvent evt) {
+ this.dispose();// TODO add your handling code here:
+ }
+
+ private void mytxtMousePressed(final java.awt.event.MouseEvent evt) {
+ this.dispose();// TODO add your handling code here:
+ }
+
+ // Variables declaration - do not modify
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JLabel mylink;
+ private javax.swing.JLabel mytxt;
+ // End of variables declaration
+
+}
diff --git a/eric/JLogoWindow.java b/eric/JLogoWindow.java
new file mode 100644
index 0000000..2d80dd5
--- /dev/null
+++ b/eric/JLogoWindow.java
@@ -0,0 +1,231 @@
+/*
+
+Copyright 2006 Eric Hakenholz
+
+This file is part of C.a.R. software.
+
+C.a.R. is a 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, version 3 of the License.
+
+C.a.R. 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, see .
+
+ */
+package eric;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Toolkit;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+
+import javax.swing.SwingUtilities;
+import rene.gui.Global;
+
+public class JLogoWindow extends JFrame {
+
+ private static int W=300, H=150;
+ private static myBar Bar=null;
+ private static int BW=280, BH=7, BY=110;// ProgressBar dimensions
+ private static volatile int BStep=0;
+ private static final double BStepMax=1996;
+ /**
+ *
+ */
+ private static final long serialVersionUID=1L;
+ private final ImageIcon backimage=new ImageIcon(getClass().getResource("/rene/zirkel/logowindow.jpg"));
+
+ public JLogoWindow(final boolean aboutBox) {
+ final Dimension dim=Toolkit.getDefaultToolkit().getScreenSize();
+ setSize(W, H);
+ this.setLocation((dim.width-W)/2, (dim.height-H)/2);
+ this.setUndecorated(true);
+ setAlwaysOnTop(true);
+ setPreferredSize(new java.awt.Dimension(W, H));
+ setResizable(false);
+ setContentPane(new myPanel());
+ if (!aboutBox) {
+ Bar=new myBar();
+ getContentPane().add(Bar);
+ }
+ }
+ static public JLogoWindow JLW;
+
+ static public void progress(String message) {
+
+// System.out.print(BStep+": "+message);
+//
+// int p=(int) Math.round((BW/BStepMax)*BStep);
+// System.out.println(" : "+p);
+ if (Bar!=null) {
+ BStep++;
+ Bar.repaint();
+ }
+ }
+
+ static public void ShowLogoWindow(final boolean aboutBox) {
+ Thread logothread=new Thread() {
+
+ @Override
+ public void run() {
+ JLW=new JLogoWindow(aboutBox);
+ if (aboutBox) {
+ JLW.addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+ DisposeLogoWindow();
+ }
+ });
+ JLW.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ DisposeLogoWindow();
+ }
+ });
+ }
+ JLW.setVisible(true);
+
+
+ // DrawString est extrêmement lent sur certaines machines virtuelles...
+ // Cela oblige à certaines contorsions si on veut que le dialogue
+ // apparaisse immédiatement avec l'image de fond, en attendant le texte...
+ JLW.repaint();
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ JLW.repaint();
+ }
+ });
+ }
+ };
+ logothread.setPriority(Thread.MAX_PRIORITY);
+ logothread.start();
+
+ }
+
+ static public void DisposeLogoWindow() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ if (JLW!=null) {
+ JLW.dispose();
+ JLW=null;
+ Bar=null;
+ BStep=0;
+ }
+ }
+ });
+
+ }
+
+ class myBar extends javax.swing.JPanel {
+
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+
+ Graphics2D g2=(Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+ RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_RENDERING,
+ RenderingHints.VALUE_RENDER_QUALITY);
+ g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+ RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
+ RenderingHints.VALUE_STROKE_PURE);
+
+ Dimension d=getSize();
+ g2.setColor(new Color(255, 255, 255, 230));
+ int p=(int) Math.round(((BW-4)/BStepMax)*BStep);
+ g2.fillRect(2, 2, p, BH-4);
+ g2.setColor(Color.white);
+ g2.drawRect(0, 0, BW, BH);
+ }
+
+ public myBar() {
+ setBounds((W-BW)/2, BY, BW, BH);
+ setOpaque(false);
+ }
+ }
+
+ class myPanel extends javax.swing.JPanel {
+
+ private boolean firstPaint=true;
+
+ public myPanel() {
+ super();
+ setLayout(null);
+ }
+
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ final Graphics2D g2=(Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+ RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_RENDERING,
+ RenderingHints.VALUE_RENDER_QUALITY);
+ g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+ RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
+ RenderingHints.VALUE_STROKE_PURE);
+
+
+ final java.awt.Dimension d=this.getSize();
+ g2.drawImage(backimage.getImage(), 0, 0, d.width, d.height, this);
+
+ if (firstPaint) {
+ firstPaint=false;
+ } else {
+ paintStrings(g2);
+ }
+
+ }
+
+ public void paintStrings(final Graphics2D g2) {
+ try {
+ g2.setFont(new Font("Dialog", Font.ITALIC, 13));
+ FontMetrics fm=g2.getFontMetrics();
+ String s=Global.Loc("splash.message");
+ g2.setColor(new Color(191, 215, 255));
+ int w=fm.stringWidth(s);
+ g2.drawString(s, (W-w)/2, 60);
+
+ g2.setFont(new Font("Dialog", Font.PLAIN, 12));
+ fm=g2.getFontMetrics();
+ s=Global.name("version")+" "+Global.name("program.version");
+ g2.setColor(Color.white);
+ w=fm.stringWidth(s);
+ g2.drawString(s, (W-w)/2, 85);
+
+ s="Java : "+System.getProperty("java.version");
+ g2.setColor(Color.white);
+ w=fm.stringWidth(s);
+ g2.drawString(s, (W-w)/2, 100);
+ } catch (Exception e) {
+ }
+ }
+ }
+}
diff --git a/eric/JMacOShandler.java b/eric/JMacOShandler.java
new file mode 100644
index 0000000..9411542
--- /dev/null
+++ b/eric/JMacOShandler.java
@@ -0,0 +1,63 @@
+/*
+
+Copyright 2006 Eric Hakenholz
+
+This file is part of C.a.R. software.
+
+C.a.R. is a 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, version 3 of the License.
+
+C.a.R. 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, see .
+
+ */
+package eric;
+
+import javax.swing.SwingUtilities;
+
+import com.apple.eawt.Application;
+import com.apple.eawt.ApplicationAdapter;
+import eric.GUI.pipe_tools;
+
+/**
+ *
+ * @author erichake
+ */
+public class JMacOShandler extends Application {
+
+ /** Creates a new instance of JMacOShandler */
+ public JMacOShandler() {
+ addApplicationListener(new OpenHandler());
+
+ }
+
+ class OpenHandler extends ApplicationAdapter {
+
+ @Override
+ public void handleOpenFile(final com.apple.eawt.ApplicationEvent evt) {
+ final String filename=evt.getFilename();
+ if (FileTools.isStartup()) {
+ FileTools.addStartupFile(filename);
+ } else {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ FileTools.open(filename);
+ }
+ });
+ }
+ }
+
+ @Override
+ public void handleQuit(final com.apple.eawt.ApplicationEvent e) {
+ pipe_tools.quitAll();
+ }
+
+
+ }
+}
diff --git a/eric/JMacroPrompt.java b/eric/JMacroPrompt.java
new file mode 100644
index 0000000..68091dd
--- /dev/null
+++ b/eric/JMacroPrompt.java
@@ -0,0 +1,249 @@
+/*
+
+Copyright 2006 Eric Hakenholz
+
+This file is part of C.a.R. software.
+
+ C.a.R. is a 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, version 3 of the License.
+
+ C.a.R. 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, see .
+
+ */
+
+
+ package eric;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.BorderFactory;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import javax.swing.SwingConstants;
+
+import rene.gui.Global;
+import rene.zirkel.ZirkelCanvas;
+import rene.zirkel.expression.Expression;
+import rene.zirkel.objects.ConstructionObject;
+import eric.bar.JProperties;
+import javax.swing.JPanel;
+import rene.gui.Global;
+
+/**
+ *
+ * @author erichake
+ */
+public class JMacroPrompt extends JDialog {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ // boolean Valid=false;
+ JTextField T = new JTextField();
+ // String S="";
+ String InitValue = "";
+ ConstructionObject OC;
+ ZirkelCanvas ZC;
+ int WindowEventCount = 0;
+ Color TitleColor = new Color(200, 200, 200);
+ Color TxtColor = new Color(250, 250, 250);
+ Color DlogColor = new Color(90, 90, 90);
+
+ private void fixsize(final JComponent cp, final int w, final int h) {
+ final Dimension d = new Dimension(w, h);
+ cp.setMaximumSize(d);
+ cp.setMinimumSize(d);
+ cp.setPreferredSize(d);
+ cp.setSize(d);
+ }
+
+ private JEricPanel margin(final int w) {
+ final JEricPanel mypan = new JEricPanel();
+ fixsize(mypan, w, 1);
+ mypan.setOpaque(false);
+ mypan.setFocusable(false);
+ return mypan;
+ }
+
+ private boolean isValidExpression(final String myexp) {
+ boolean bool = true;
+ try {
+ final Expression exp = new Expression(myexp, OC.getConstruction(),
+ OC);
+ if (!(exp.isValid()))
+ bool = false;
+ } catch (final Exception ex) {
+ bool = false;
+ }
+ return bool;
+ }
+
+ public JMacroPrompt(final Frame f, final ZirkelCanvas zc,
+ final String oName, final ConstructionObject oc) {
+ super(f, true);
+ OC = oc;
+ ZC = zc;
+
+ try {
+ InitValue = String.valueOf(OC.getValue());
+ } catch (final Exception ex) {
+ }
+
+ final JPanel content = (JPanel) this.getContentPane();
+ this.setUndecorated(true);
+ content.setLayout(new javax.swing.BoxLayout(content,
+ javax.swing.BoxLayout.Y_AXIS));
+ content.setBackground(DlogColor);
+ // this.setBackground(new Color(0.2f, 0.2f, 0.2f, 0.5f));
+ // content.setOpaque(false);
+
+ final JLabel p1 = new JLabel(Global.name("macro.prompt.prompt") + " :");
+ p1.setHorizontalAlignment(SwingConstants.CENTER);
+ fixsize(p1, 300, 15);
+ p1.setAlignmentX(0.5f);
+ p1.setOpaque(false);
+ p1.setFont(new java.awt.Font(Global.GlobalFont, 1, 12));
+ p1.setForeground(TitleColor);
+
+ final JEricPanel p2 = new JEricPanel();
+ p2
+ .setLayout(new javax.swing.BoxLayout(p2,
+ javax.swing.BoxLayout.X_AXIS));
+ final JLabel p21 = new JLabel(oName);
+ final JButton okbtn = new JButton();
+ okbtn.setIcon(new ImageIcon(getClass().getResource(
+ "/eric/GUI/icons/palette/Mvalid.png")));
+ okbtn.setBorder(BorderFactory.createEmptyBorder());
+ okbtn.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(final MouseEvent e) {
+ doclose();
+ }
+ });
+ okbtn.setContentAreaFilled(false);
+ final JButton cancelbtn = new JButton();
+ cancelbtn.setIcon(new ImageIcon(getClass().getResource(
+ "/eric/GUI/icons/palette/Mcancel.png")));
+ cancelbtn.setBorder(BorderFactory.createEmptyBorder());
+ cancelbtn.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(final MouseEvent e) {
+ T.setText(InitValue);
+ try {
+ OC.setExpression(T.getText(), OC.getConstruction());
+ OC.setSlider(false);
+ } catch (final Exception ex) {
+ }
+ ZC.recompute();
+ ZC.validate();
+ ZC.repaint();
+ T.requestFocus();
+ T.selectAll();
+ }
+ });
+ cancelbtn.setContentAreaFilled(false);
+ fixsize(p21, 120, 18);
+ fixsize(T, 118, 18);
+ p2.add(margin(5));
+ p2.add(p21);
+ p2.add(margin(10));
+ p2.add(T);
+ p2.add(margin(5));
+ p2.add(cancelbtn);
+ p2.add(margin(5));
+ p2.add(okbtn);
+ p2.add(margin(5));
+
+ fixsize(p2, 300, 30);
+ p2.setAlignmentX(0.5f);
+ p2.setOpaque(false);
+ p21.setOpaque(false);
+ p21.setFont(new java.awt.Font(Global.GlobalFont, 1, 12));
+ T.setFont(new java.awt.Font(Global.GlobalFont, 1, 12));
+ p21.setForeground(TxtColor);
+ T.setText(JProperties.Point_To_Comma(InitValue, OC.getConstruction(),
+ true));
+
+ content.add(p1);
+ content.add(p2);
+
+ T.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(final KeyEvent e) {
+ if ((e.getKeyCode() == KeyEvent.VK_ENTER)
+ || (e.getKeyCode() == KeyEvent.VK_ESCAPE)) {
+ doclose();
+ }
+
+ }
+
+ @Override
+ public void keyReleased(final KeyEvent e) {
+ final String e1 = JProperties.Comma_To_Point(T.getText(), OC
+ .getConstruction(), true);
+ final String myexp = (isValidExpression(e1)) ? e1 : "invalid";
+ try {
+ OC.setExpression(myexp, OC.getConstruction());
+ OC.setSlider(false);
+ } catch (final Exception ex) {
+ }
+ ZC.recompute();
+ ZC.validate();
+ ZC.repaint();
+ }
+ });
+
+ this.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowOpened(final WindowEvent e) {
+ T.requestFocus();
+ T.selectAll();
+ }
+ });
+
+ pack();
+ final Point pt = zc.getLocationOnScreen();
+ pt.x += zc.getSize().width / 2 - this.getSize().width / 2;
+ pt.y += zc.getSize().height - this.getSize().height;
+ this.setLocation(pt);
+ this.setVisible(true);
+ }
+
+ public void doclose() {
+ final String e1 = JProperties.Comma_To_Point(T.getText(), OC
+ .getConstruction(), true);
+ final String myexp = (isValidExpression(e1)) ? e1 : InitValue;
+
+ try {
+ OC.setExpression(myexp, OC.getConstruction());
+ OC.setSlider(false);
+ } catch (final Exception ex) {
+ }
+ ZC.recompute();
+ ZC.validate();
+ ZC.repaint();
+ setVisible(false);
+ dispose();
+ }
+
+}
diff --git a/eric/JPointName.java b/eric/JPointName.java
new file mode 100644
index 0000000..19efbf4
--- /dev/null
+++ b/eric/JPointName.java
@@ -0,0 +1,278 @@
+/*
+
+Copyright 2006 Eric Hakenholz
+
+This file is part of C.a.R. software.
+
+ C.a.R. is a 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, version 3 of the License.
+
+ C.a.R. 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, see .
+
+ */
+
+
+ package eric;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import eric.JEricPanel;
+import javax.swing.SwingConstants;
+
+import rene.gui.Global;
+import rene.zirkel.construction.Construction;
+import rene.zirkel.objects.ConstructionObject;
+
+/**
+ *
+ * @author erichake
+ */
+public class JPointName {
+ // private String StartLetter="\u03b6";
+ private static String GenericLetter = "P";
+ private static String majLettersSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ private static String minLettersSet = "abcdefghijklmnopqrstuvwxyz";
+ private static String greekmajLettersSet = "\u0391\u0392\u0393\u0394\u0395\u0396"
+ + "\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\u03A3"
+ + "\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9";
+ private static String greekminLettersSet = "\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9"
+ + "\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C3\u03C4\u03C5\u03C6"
+ + "\u03C7\u03C8\u03C9";
+ private static ArrayList LettersSet = new ArrayList();
+
+ private String LetterSuffix = "";
+ // Ct should be the ZF.ZC.getConstruction() object :
+ private Construction ZCcn = null;
+ private JButton PaletteBtn = null;
+ private JZirkelCanvas JZF = null;
+
+ public static int minLettersSetCode = 1;
+
+ // private String Letters=majLettersSet;
+ // 0:majLettersSet , 1:minLettersSet , 2:greekmajLettersSet ,
+ // 3:greekminLettersSet
+ private int LetterSetCode = 0;
+ private int StartLetter = 0;
+
+ /**
+ * Creates a new instance of JPointLabel
+ *
+ * @param jzf
+ */
+ public JPointName(final JZirkelCanvas jzf) {
+ JZF = jzf;
+ ZCcn = JZF.getZF().ZC.getConstruction();
+ PaletteBtn = new JPaletteButton(JZF);
+ }
+
+ public JPointName() {
+ LettersSet.add(majLettersSet);
+ LettersSet.add(minLettersSet);
+ LettersSet.add(greekmajLettersSet);
+ LettersSet.add(greekminLettersSet);
+ }
+
+ public String getCurrentLetterSet() {
+ return (String) LettersSet.get(LetterSetCode);
+ }
+
+ public int getCurrentLetterSetCode() {
+ return LetterSetCode;
+ }
+
+ static void fixsize(final Component cp, final int w, final int h) {
+ final Dimension d = new Dimension(w, h);
+ cp.setMaximumSize(d);
+ cp.setMinimumSize(d);
+ cp.setPreferredSize(d);
+ cp.setSize(d);
+ }
+
+ public JButton getPaletteButton(){
+ return PaletteBtn;
+ }
+
+ public void addPaletteJLabel(final JEricPanel jp) {
+ fixsize(PaletteBtn, 28, jp.getSize().height);
+ jp.add(PaletteBtn);
+ }
+
+ public void setEnabledJLabel(final boolean bool) {
+ PaletteBtn.setEnabled(bool);
+
+ }
+
+ public void addSuffixChar() {
+ if (LetterSuffix.equals("''"))
+ LetterSuffix = "";
+ else
+ LetterSuffix += "'";
+ }
+
+ void setSuffixChar(final String suff) {
+ LetterSuffix = suff;
+ }
+
+ public static String getGenericName(final Construction myC) {
+ int i = 1;
+ ConstructionObject o = myC.find(GenericLetter + i);
+ while (o != null) {
+ i++;
+ o = myC.find(GenericLetter + i);
+ }
+
+ return (GenericLetter + i);
+ }
+
+ public String getBetterName(final Construction myC,
+ final boolean setPaletteTxt) {
+ final String Letters = getCurrentLetterSet();
+ String s = Letters.substring(StartLetter, StartLetter + 1);
+ if (ZCcn == null) {
+ s = getGenericName(myC);
+ } else if (Global.getParameter("options.point.shownames", false)) {
+ int i = Letters.indexOf(s);
+ final int k = i;
+ s += LetterSuffix;
+ ConstructionObject o = ZCcn.find(s);
+ while ((i < (Letters.length() - 1)) && (o != null)) {
+ i++;
+ s = Letters.substring(i, i + 1) + LetterSuffix;
+ o = ZCcn.find(s);
+ }
+
+ i = -1;
+ while ((i < k) && (o != null)) {
+ i++;
+ s = Letters.substring(i, i + 1) + LetterSuffix;
+ o = ZCcn.find(s);
+ }
+
+ if (o != null) {
+ s = getGenericName(ZCcn);
+ }
+
+ } else
+ s = getGenericName(ZCcn);
+ if ((PaletteBtn != null) && (setPaletteTxt))
+ PaletteBtn.setText(s);
+ return s;
+ }
+
+ public static int findSet(final String s) {
+ for (int i = 0; i < LettersSet.size(); i++) {
+ final String mySet = (String) LettersSet.get(i);
+ if (mySet.indexOf(s) != -1)
+ return i;
+ }
+ return -1;
+ }
+
+ public boolean isLetterAllowed(final String s) {
+ return (getCurrentLetterSet().indexOf(s) != -1);
+ }
+
+ public boolean isLetterAccepted(final String s) {
+ if (ZCcn != null)
+ return (ZCcn.find(s) == null);
+ else
+ return false;
+ }
+
+ public String setStartLetter(final String s) {
+ if (isLetterAllowed(s)) {
+ StartLetter = getCurrentLetterSet().indexOf(s);
+ }
+
+ return getBetterName(null, true);
+ }
+
+ public String setLetterSet(final int i) {
+ LetterSetCode = i;
+ StartLetter = 0;
+ return getBetterName(null, true);
+ }
+
+}
+
+class JPaletteButton extends JButton implements MouseListener {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final JZirkelCanvas JZF;
+ int[] x = { 0, 10, 0 };
+ int[] y = { 0, 10, 10 };
+
+ @Override
+ public void paintComponent(final java.awt.Graphics g) {
+
+ final Dimension d = this.getSize();
+
+ final int sze = 6;
+ x[0] = d.width - sze;
+ y[0] = d.height;
+ x[1] = d.width;
+ y[1] = d.height - sze;
+ x[2] = d.width;
+ y[2] = d.height;
+ final Graphics2D g2 = (Graphics2D) g;
+
+ g2.setComposite(AlphaComposite.SrcOver);
+ g2.setColor(new Color(50, 50, 50));
+ g2.fillPolygon(x, y, 3);
+
+ g2
+ .setComposite(AlphaComposite.getInstance(
+ AlphaComposite.SRC_OVER, 1f));
+ super.paintComponent(g);
+ }
+
+ public JPaletteButton(final JZirkelCanvas jzf) {
+ JZF = jzf;
+ setOpaque(false);
+ setContentAreaFilled(false);
+ setBorder(BorderFactory.createEmptyBorder());
+ setFont(new java.awt.Font(Global.GlobalFont, 1, 14));
+ setForeground(new Color(50, 50, 50));
+ setHorizontalAlignment(SwingConstants.CENTER);
+ setVerticalAlignment(SwingConstants.CENTER);
+ addMouseListener(this);
+ }
+
+ public void mouseClicked(final MouseEvent e) {
+ }
+
+ public void mousePressed(final MouseEvent e) {
+ System.out.println("mousePressed");
+ if (isEnabled()) {
+ JZF.getZF().setinfo("nom_points", false);
+ new JCharacterPalette(JZF, this);
+ }
+ }
+
+ public void mouseReleased(final MouseEvent e) {
+ }
+
+ public void mouseEntered(final MouseEvent e) {
+ }
+
+ public void mouseExited(final MouseEvent e) {
+ }
+}
diff --git a/eric/JSelectPopup.java b/eric/JSelectPopup.java
new file mode 100644
index 0000000..a4fcba3
--- /dev/null
+++ b/eric/JSelectPopup.java
@@ -0,0 +1,208 @@
+/*
+
+Copyright 2006 Eric Hakenholz
+
+This file is part of C.a.R. software.
+
+ C.a.R. is a 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, version 3 of the License.
+
+ C.a.R. 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, see .
+
+ */
+
+
+ package eric;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.MouseInfo;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.Vector;
+
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
+
+import rene.gui.Global;
+import rene.util.MyVector;
+import rene.zirkel.ZirkelCanvas;
+import rene.zirkel.objects.ConstructionObject;
+import rene.zirkel.tools.EditTool;
+
+/**
+ *
+ * @author erichake
+ */
+// This class is only instanciated by JSelectPopup
+// It is a "modal" popup for complex tools. Popup menu appear
+// in a 1 pixel w/h modal JDialog : it seems it's in ZirkelCanvas, but it's
+// not...
+public class JSelectPopup extends JPopupMenu implements MouseListener,
+PopupMenuListener {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static int xclic,yclic;
+ private static boolean iscaller=false;
+ ZirkelCanvas ZC;
+ Vector V = new Vector();
+ String CallerObject = "RightClick";
+ boolean RightClicked;
+
+ public JSelectPopup(final ZirkelCanvas zc,final MyVector v, boolean RightClicked) {
+ init(zc, v);
+ addPopupMenuListener(this);
+ Point loc=MouseInfo.getPointerInfo().getLocation();
+ SwingUtilities.convertPointFromScreen(loc, zc);
+ xclic=loc.x;
+ yclic=loc.y;
+ show(zc, loc.x, loc.y);
+ this.RightClicked = RightClicked;
+ }
+
+ public void init(final ZirkelCanvas zc, final MyVector v) {
+ ZC = zc;
+ // A bit of a hack : need to know where was the calling method...
+ // getStackTrace stores the whole history of caller methods
+ final StackTraceElement[] trace = new Throwable().getStackTrace();
+ for (final StackTraceElement element : trace) {
+ if (element.getClassName().startsWith("rene.zirkel.tools")) {
+ final String s = element.getClassName();
+ CallerObject = s.split("\\.")[3];
+ break;
+ }
+ }
+
+ String aa = "";
+
+ try {
+ aa = Global.Loc("selectpopup." + CallerObject);
+ } catch (final Exception e) {
+ }
+
+ JMenuItem m = new JMenuItem(aa + Global.Loc("selectpopup.whatobject"));
+
+ m.setBackground(Color.WHITE);
+ m.setForeground(Color.DARK_GRAY);
+
+ m.setFont(new Font("Dialog", 3, 12));
+ m.setActionCommand("-1,false");
+
+ m.setEnabled(false);
+ m.addMouseListener(this);
+ this.add(m);
+
+ for (int i = 0; i < v.size(); i++) {
+ final ConstructionObject o = (ConstructionObject) v.elementAt(i);
+ V.add(o);
+ final String tp = o.getName() + " : " + o.getText().split(" ")[0];
+ m = new JMenuItem(tp);
+ m.setForeground(o.getColor());
+ m.setBackground(new Color(240, 240, 240));
+ m.setFont(new Font("Dialog", 1, 12));
+
+ m.setActionCommand(String.valueOf(i) + "," + o.selected());
+ m.setRolloverEnabled(true);
+
+ m.addMouseListener(this);
+ m.addActionListener(new ActionListener() {
+ public void actionPerformed(final ActionEvent event) {
+ final JMenuItem jm = (JMenuItem) event.getSource();
+ doaction(jm.getActionCommand(), event.getModifiers());
+ }
+ });
+ this.add(m);
+ }
+
+
+ }
+
+ public static int getMouseX(){
+ return xclic;
+ }
+ public static int getMouseY(){
+ return yclic;
+ }
+ public static boolean isCallerObject(){
+ return iscaller;
+ }
+
+ public int row(final String str) {
+ return Integer.parseInt(str.split(",")[0]);
+ }
+
+ public boolean sel(final String str) {
+ final String bl = str.split(",")[1].toLowerCase();
+ return (bl.equals("true"));
+ }
+
+ public void doaction(final String str, final int modifier) {
+ final ConstructionObject o = (ConstructionObject) V.elementAt(row(str));
+ o.setSelected(sel(str));
+ iscaller=true;
+ if(RightClicked){
+ ZC.clearSelected();
+ eric.bar.JPropertiesBar.EditObject(o, true, false);
+ } else {
+// System.out.println(o.getName());
+ ZC.setConstructionObject(o);
+ }
+ iscaller=false;
+ }
+
+ public void mouseClicked(final MouseEvent e) {
+ }
+
+ public void mousePressed(final MouseEvent e) {
+ }
+
+ public void mouseReleased(final MouseEvent e) {
+ }
+
+ public void mouseEntered(final MouseEvent e) {
+ final JMenuItem jm = (JMenuItem) e.getSource();
+ final int i = row(jm.getActionCommand());
+ if ((i > -1) && (!sel(jm.getActionCommand()))) {
+ final ConstructionObject o = (ConstructionObject) V.elementAt(i);
+ o.setSelected(true);
+ ZC.repaint();
+ }
+ }
+
+ public void mouseExited(final MouseEvent e) {
+ final JMenuItem jm = (JMenuItem) e.getSource();
+ final int i = row(jm.getActionCommand());
+ if ((i > -1) && (!sel(jm.getActionCommand()))) {
+ final ConstructionObject o = (ConstructionObject) V.elementAt(i);
+ o.setSelected(false);
+ ZC.repaint();
+ }
+ }
+
+ //
+ public void popupMenuWillBecomeVisible(final PopupMenuEvent e) {
+ }
+
+ public void popupMenuWillBecomeInvisible(final PopupMenuEvent e) {
+ }
+
+ public void popupMenuCanceled(final PopupMenuEvent e) {
+ }
+
+}
diff --git a/eric/JSprogram/.DS_Store b/eric/JSprogram/.DS_Store
new file mode 100644
index 0000000..d2ce7cd
Binary files /dev/null and b/eric/JSprogram/.DS_Store differ
diff --git a/eric/JSprogram/.cvsignore b/eric/JSprogram/.cvsignore
new file mode 100755
index 0000000..e43b0f9
--- /dev/null
+++ b/eric/JSprogram/.cvsignore
@@ -0,0 +1 @@
+.DS_Store
diff --git a/eric/JSprogram/Const.java b/eric/JSprogram/Const.java
new file mode 100644
index 0000000..8c158f8
--- /dev/null
+++ b/eric/JSprogram/Const.java
@@ -0,0 +1,31 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package eric.JSprogram;
+
+
+
+/**
+ *
+ * @author erichake
+ */
+public class Const{
+ public double BLA=3.5;
+public Const(){
+
+}
+public double getBLA(){
+ return BLA;
+}
+
+public double m(String a,String b){
+ return 1.0;
+}
+
+public double m(String a){
+ return 2.0;
+}
+
+}
diff --git a/eric/JSprogram/JSBlankIcon.java b/eric/JSprogram/JSBlankIcon.java
new file mode 100644
index 0000000..a33f927
--- /dev/null
+++ b/eric/JSprogram/JSBlankIcon.java
@@ -0,0 +1,31 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package eric.JSprogram;
+
+import java.awt.Dimension;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+
+/**
+ *
+ * @author erichake
+ */
+public class JSBlankIcon extends JButton{
+public JSBlankIcon(int size) {
+ this.setBorder(BorderFactory.createEmptyBorder());
+ fixsize(size);
+ this.setContentAreaFilled(false);
+ this.setOpaque(false);
+ }
+
+private void fixsize(final int sze) {
+ final Dimension d=new Dimension(sze, sze);
+ this.setMaximumSize(d);
+ this.setMinimumSize(d);
+ this.setPreferredSize(d);
+ this.setSize(d);
+ }
+}
diff --git a/eric/JSprogram/JSButton.java b/eric/JSprogram/JSButton.java
new file mode 100644
index 0000000..f17566b
--- /dev/null
+++ b/eric/JSprogram/JSButton.java
@@ -0,0 +1,144 @@
+/*
+
+Copyright 2006 Eric Hakenholz
+
+This file is part of C.a.R. software.
+
+C.a.R. is a 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, version 3 of the License.
+
+C.a.R. 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, see .
+
+ */
+package eric.JSprogram;
+
+import eric.GUI.themes;
+import eric.JZirkelCanvas;
+import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.Stroke;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.image.FilteredImageSource;
+import java.awt.image.ImageFilter;
+
+import javax.swing.BorderFactory;
+import javax.swing.GrayFilter;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import rene.zirkel.ZirkelCanvas;
+
+public class JSButton extends JButton implements MouseListener {
+
+// private final ImageIcon myimage;
+ int iconsize=24;
+ boolean isEntered=false; // Mouseover ?
+ boolean isDisabled;
+ private String Name;
+
+ // String Shortcut;
+ @Override
+ public void paintComponent(final java.awt.Graphics g) {
+ final java.awt.Dimension d=this.getSize();
+ final int w=d.width;
+ final int h=d.height;
+
+ if (g==null) {
+ return;
+ }
+
+ super.paintComponent(g);
+ final Graphics2D g2=(Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+ RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_RENDERING,
+ RenderingHints.VALUE_RENDER_QUALITY);
+ g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+ RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
+ RenderingHints.VALUE_STROKE_PURE);
+ if (isDisabled) {
+ final ImageFilter filter=new GrayFilter(true, 60);
+ final Image disImage=createImage(new FilteredImageSource(themes.getPaletteImage(Name).getSource(), filter));
+ final ImageIcon myicn=new ImageIcon(disImage);
+ g2.drawImage(myicn.getImage(), 0, 0, w, h, this);
+ return;
+ }
+ //not elegant... just for one icon...
+ if(Name.equals("monkey")){
+ g2.drawImage(themes.resizeExistingIcon("/eric/GUI/icons/themes/common/monkeybtn_off.png", 22, 15).getImage(), 1, 4, 22, 15, this);
+ } else {
+ g2.drawImage(themes.getPaletteImage(Name), 0, 0, w, h, this);
+ }
+
+ if (isEntered) {
+ final AlphaComposite ac=AlphaComposite.getInstance(
+ AlphaComposite.SRC_OVER, 0.1f);
+ g2.setComposite(ac);
+ g2.setColor(new Color(0, 0, 80));
+ final Stroke stroke=new BasicStroke(3f);
+ g2.setStroke(stroke);
+ g2.drawRect(1, 1, w-2, h-2);
+
+ }
+ }
+
+ public JSButton(String name, int size,boolean enabled) {
+ isDisabled=!enabled;
+ iconsize=size;
+ Name=name;
+ this.setBorder(BorderFactory.createEmptyBorder());
+ fixsize(iconsize);
+ this.addMouseListener(this);
+ this.setContentAreaFilled(false);
+ this.setOpaque(false);
+ this.setFocusable(false);
+ }
+
+
+
+ private void fixsize(final int sze) {
+ final Dimension d=new Dimension(sze, sze);
+ this.setMaximumSize(d);
+ this.setMinimumSize(d);
+ this.setPreferredSize(d);
+ this.setSize(d);
+ }
+
+ public void mouseClicked(MouseEvent e) {
+ }
+
+ public void mousePressed(MouseEvent e) {
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ public void mouseEntered(final MouseEvent e) {
+ isEntered=true;
+ repaint();
+
+ }
+
+ public void mouseExited(final MouseEvent e) {
+ isEntered=false;
+ repaint();
+
+ }
+}
+
+
diff --git a/eric/JSprogram/JSEditor.form b/eric/JSprogram/JSEditor.form
new file mode 100644
index 0000000..75689c6
--- /dev/null
+++ b/eric/JSprogram/JSEditor.form
@@ -0,0 +1,877 @@
+
+
+
diff --git a/eric/JSprogram/JSEditor.java b/eric/JSprogram/JSEditor.java
new file mode 100644
index 0000000..f7f5bd3
--- /dev/null
+++ b/eric/JSprogram/JSEditor.java
@@ -0,0 +1,2977 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * JConsole2.java
+ *
+ * Created on 20 avr. 2009, 08:24:41
+ * by Éric Hakenholz,
+ * with somme addons by Alain Busser
+ * wwith addons by Patrice Debrabant
+ */
+package eric.JSprogram;
+
+import eric.JBrowserLauncher;
+import eric.JZirkelCanvas;
+import eric.OS;
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Insets;
+import java.awt.MouseInfo;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.JTextPane;
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
+import javax.swing.ToolTipManager;
+import javax.swing.border.BevelBorder;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.event.UndoableEditEvent;
+import javax.swing.event.UndoableEditListener;
+import javax.swing.text.AbstractDocument;
+import javax.swing.text.Element;
+import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyledDocument;
+import javax.swing.text.TabSet;
+import javax.swing.text.TabStop;
+import javax.swing.undo.CannotRedoException;
+import javax.swing.undo.CannotUndoException;
+import javax.swing.undo.UndoManager;
+import javax.swing.undo.UndoableEdit;
+import rene.gui.Global;
+
+/**
+ *
+ * @author erichake
+ */
+public class JSEditor extends javax.swing.JFrame {
+
+// final UndoManager undo=new UndoManager();
+ StyledDocument doc;
+ final int ctrlkey=(OS.isMac())?InputEvent.META_DOWN_MASK
+ :InputEvent.CTRL_DOWN_MASK;
+ private boolean NoTypeNoClic=true;
+ UndoManager undo;
+ private Point origin;
+ private Point winloc;
+ private Point current;
+ private int xx;
+ private int yy;
+ private int w;
+ private int h;
+ private int JSsel=0;
+ private Pattern p;
+ private boolean matchFound = false;
+ protected static int TailleTexte=16;
+ private String filename=""; // script in file
+ private String scriptname=""; // script in figure
+ private ScriptItem ITEM;
+ private boolean FlagSimp=false; // Dibs : drapeau interface simplifiée
+ private boolean infrench; // Dibs
+ private boolean pseudoCode=false;
+ private boolean ancienPseudoCode=false;
+
+ /** Creates new form JConsole2 */
+ public JSEditor(ScriptItem item) {
+ infrench = Global.getParameter("language", "").equals("fr");
+ ITEM=item;
+ initComponents();
+ if (JZirkelCanvas.getCurrentZC().is3D()){
+ c_carmetal.setMaximumSize(new java.awt.Dimension(182, 380));
+ c_carmetal.setMinimumSize(new java.awt.Dimension(182, 370));
+ c_carmetal.setPreferredSize(new java.awt.Dimension(182, 370));
+ }
+ else {
+ c_carmetal.setMaximumSize(new java.awt.Dimension(182, 290));
+ c_carmetal.setMinimumSize(new java.awt.Dimension(182, 280));
+ c_carmetal.setPreferredSize(new java.awt.Dimension(182, 280));
+ }
+ doc=script_area.getStyledDocument();
+ initCaRMetalBtns();
+ initScriptArea();
+ initUndoRedo();
+ initJSlist();
+ setWindowTitle(Loc("JSeditor.title"));
+ if ((OS.isMac())) {
+ fixsize(macpanel, 1, 1);
+ winpanel.removeAll();
+ winpanel.add(title_lbl);
+ winpanel.revalidate();
+ } else {
+ fixsize(winpanel, 1, 1);
+ }
+ this.setLocationRelativeTo(JZirkelCanvas.getCurrentZC());
+ errorpanel.removeAll();
+ errorpanel.revalidate();
+
+ setTabs(script_area, 3);
+ setSize(920, 690);
+
+ // Show tool tips immediately
+ ToolTipManager.sharedInstance().setInitialDelay(50);
+ setVisible(true);
+
+
+ }
+
+ public void setBackBtnEnabled(boolean bool) {
+ backbtn.setEnabled(bool);
+ }
+
+ public void setScriptName(String s) {
+ scriptname=s;
+ }
+
+ public String getScriptName() {
+ return scriptname;
+ }
+
+ public void setFileName(String s) {
+ filename=s;
+ }
+
+ public String getFileName() {
+ return filename;
+ }
+
+ public void setWindowTitle(String s) {
+ title_lbl.setText(s);
+ }
+
+ public String getWindowTitle() {
+ return title_lbl.getText();
+ }
+
+ public boolean isFileOpened() {
+ return !(filename.equals(""));
+ }
+
+ private void initJSlist() {
+ }
+
+ static void fixsize(final JComponent cp, final int w, final int h) {
+ final Dimension d=new Dimension(w, h);
+ cp.setMaximumSize(d);
+ cp.setMinimumSize(d);
+ cp.setPreferredSize(d);
+ cp.setSize(d);
+ }
+
+ public void NoTypeNoClic() {
+ NoTypeNoClic=true;
+ }
+
+ public void addOrChange(String st) {
+ if (NoTypeNoClic) {
+ undo.undo();
+ } else {
+ NoTypeNoClic();
+ }
+ addToScript(st);
+ }
+
+ public void addToScript(String st) {
+ script_area.requestFocus();
+ script_area.replaceSelection(st);
+// syntaxColoring();
+ script_area.requestFocus();
+ }
+
+ public void clearSelection() {
+ script_area.replaceSelection("");
+ script_area.requestFocus();
+ }
+
+ public JSIcon addCMicon(String obj, String syntax) {
+ JSIcon jsi=new JSIcon(this, obj, syntax);
+ jsi.setToolTipText(Loc("JSeditor."+obj));
+ c_carmetal.add(jsi);
+ return jsi;
+ }
+
+ /**
+ *
+ * @param obj
+ * @param example
+ * @return
+ */
+ public JSButton addJSIcon(String obj, final String example) {
+ JSButton jb=new JSButton(obj, 24, true);
+ jb.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ addToScript(example);
+ }
+ });
+ js_btns.add(jb);
+ return jb;
+ }
+
+ public JSButton addCMicon2(String obj, final String example) { //Dibs
+ JSButton jb=new JSButton(obj, 24, true);
+ jb.setToolTipText(Loc("JSeditor."+obj));
+ jb.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ addToScript(example);
+ }
+ });
+ c_carmetal.add(jb);
+ return jb;
+ }
+
+ public void addBlankIcon(int nb, int size) {
+ for (int i=0; i=)", Pattern.MULTILINE);
+ m = p.matcher(scp);
+ matchFound = m.find();
+ while (matchFound) {
+ posCurseur=script_area.getCaretPosition();
+ scp= m.replaceFirst(String.valueOf(m.group(1))+"≥");
+ script_area.setText(scp);
+ try {
+ script_area.setCaretPosition(posCurseur-1);
+ }
+ catch(Exception e) {
+ }
+ m = p.matcher(scp);
+ matchFound = m.find();
+ }
+ p = Pattern.compile("(^[^\"]+(?:\"[^\"]*\"[^\"]*)+[^\"\n]*)(?:>=)", Pattern.MULTILINE);
+ m = p.matcher(scp);
+ matchFound = m.find();
+ while (matchFound) {
+ posCurseur=script_area.getCaretPosition();
+ scp= m.replaceFirst(String.valueOf(m.group(1))+"≥");
+ script_area.setText(scp);
+ try {
+ script_area.setCaretPosition(posCurseur-1);
+ }
+ catch(Exception e) {
+ }
+ m = p.matcher(scp);
+ matchFound = m.find();
+ }
+ p = Pattern.compile("(^[^\"]*)(?:!=)", Pattern.MULTILINE);
+ m = p.matcher(scp);
+ matchFound = m.find();
+ while (matchFound) {
+ posCurseur=script_area.getCaretPosition();
+ scp= m.replaceFirst(String.valueOf(m.group(1))+"≠");
+ script_area.setText(scp);
+ try {
+ script_area.setCaretPosition(posCurseur-1);
+ }
+ catch(Exception e) {
+ }
+ m = p.matcher(scp);
+ matchFound = m.find();
+ }
+ p = Pattern.compile("(^[^\"]+(?:\"[^\"]*\"[^\"]*)+[^\"\n]*)(?:!=)", Pattern.MULTILINE);
+ m = p.matcher(scp);
+ matchFound = m.find();
+ while (matchFound) {
+ posCurseur=script_area.getCaretPosition();
+ scp= m.replaceFirst(String.valueOf(m.group(1))+"≠");
+ script_area.setText(scp);
+ try {
+ script_area.setCaretPosition(posCurseur-1);
+ }
+ catch(Exception e) {
+ }
+ m = p.matcher(scp);
+ matchFound = m.find();
+ }
+ p = Pattern.compile("(^[^\"]*)\\*", Pattern.MULTILINE);
+ m = p.matcher(scp);
+ matchFound = m.find();
+ while (matchFound) {
+ posCurseur=script_area.getCaretPosition();
+ scp= m.replaceFirst(String.valueOf(m.group(1))+"×");
+ script_area.setText(scp);
+ try {
+ script_area.setCaretPosition(posCurseur);
+ }
+ catch(Exception e) {
+ }
+ m = p.matcher(scp);
+ matchFound = m.find();
+ }
+ p = Pattern.compile("(^[^\"]+(?:\"[^\"]*\"[^\"]*)+[^\"\n]*)\\*", Pattern.MULTILINE);
+ m = p.matcher(scp);
+ matchFound = m.find();
+ while (matchFound) {
+ posCurseur=script_area.getCaretPosition();
+ scp= m.replaceFirst(String.valueOf(m.group(1))+"×");
+ script_area.setText(scp);
+ try {
+ script_area.setCaretPosition(posCurseur);
+ }
+ catch(Exception e) {
+ }
+ m = p.matcher(scp);
+ matchFound = m.find();
+ }
+ p = Pattern.compile("(^[^\"]*)Infinity", Pattern.MULTILINE);
+ m = p.matcher(scp);
+ matchFound = m.find();
+ while (matchFound) {
+ posCurseur=script_area.getCaretPosition();
+ scp= m.replaceFirst(String.valueOf(m.group(1))+"∞");
+ script_area.setText(scp);
+ try {
+ script_area.setCaretPosition(posCurseur-7);
+ }
+ catch(Exception e) {
+ }
+ m = p.matcher(scp);
+ matchFound = m.find();
+ }
+ p = Pattern.compile("(^[^\"]+(?:\"[^\"]*\"[^\"]*)+[^\"\n]*)Infinity", Pattern.MULTILINE);
+ m = p.matcher(scp);
+ matchFound = m.find();
+ while (matchFound) {
+ posCurseur=script_area.getCaretPosition();
+ scp= m.replaceFirst(String.valueOf(m.group(1))+"∞");
+ script_area.setText(scp);
+ try {
+ script_area.setCaretPosition(posCurseur-7);
+ }
+ catch(Exception e) {
+ }
+ m = p.matcher(scp);
+ matchFound = m.find();
+ }
+ }
+ else {
+ pseudoCode=false;
+ if (ancienPseudoCode) {
+ js_btns.removeAll();
+ c_carmetal.removeAll();
+ initCaRMetalBtns();
+ js_btns.revalidate();
+ c_carmetal.revalidate();
+ ancienPseudoCode=false;
+ }
+ }
+ scp="\n"+scp+"\n";
+// scp=scp.replace("(", "@").replace(")", "@");
+
+ //CaRMetal javascript instructions coloring :
+ String[] allnames=JSFunctions.getKeywords();
+ ArrayList carmetal_matches=new ArrayList();
+ for (int i=1; i js_matches=new ArrayList();
+ for (int i=0; i js_maths_matches=new ArrayList();
+ if (pseudoCode) {
+ for (int i=0; i js_comments=new ArrayList();
+// Matcher m = Pattern.compile("[\n\t]+(\\Q//\\E[^\n]*)", Pattern.MULTILINE).matcher(scp);
+ Matcher m=Pattern.compile("(\\Q//\\E[^\n]*)", Pattern.MULTILINE).matcher(scp);
+ while (m.find()) {
+ js_comments.add(m.start(1)-1);
+ js_comments.add(m.end(1)-1);
+// System.out.println("start="+m.start(1)+" end="+m.end(1));
+// m = Pattern.compile("/\\*([^*]|\\*+[^*/])*\\*+/").matcher(scp);
+// m = Pattern.compile("(\\/\\*.*\\*\\/)").matcher(scp);
+// while (m.find()) {
+// js_comments.add(m.start(1) - 1);
+// js_comments.add(m.end(1) - 1);
+// marche pas, je sais pas pourquoi
+ }
+// }
+
+ // Text coloring :
+ ArrayList text_matches=new ArrayList();
+ m=Pattern.compile("\"([^\"]*)\"", Pattern.MULTILINE).matcher(scp);
+ while (m.find()) {
+ text_matches.add(m.start(1)-1);
+ text_matches.add(m.end(1)-1);
+// System.out.println("start="+m.start(1)+" end="+m.end(1));
+ }
+
+ // Number coloring :
+ ArrayList number_matches=new ArrayList();
+// m = Pattern.compile("[\\+\\-]?\\d+(\\.\\d*)?([Ee][\\+\\-]?\\d+)?", Pattern.MULTILINE).matcher(scp);
+ m=Pattern.compile("([0-9\\.]+)", Pattern.MULTILINE).matcher(scp);
+// m = Pattern.compile("([0-9\\.\\+\\-]+)", Pattern.MULTILINE).matcher(scp);
+ while (m.find()) {
+ number_matches.add(m.start(1)-1);
+ number_matches.add(m.end(1)-1);
+// System.out.println("start="+m.start(1)+" end="+m.end(1));
+ }
+
+ doc.setCharacterAttributes(0, script_area.getText().length(), script_area.getStyle("Normal"), true);
+
+ for (int i=0; i,,)");
+ addCMicon("intersection", "Intersection(,,)");
+ addCMicon("midpoint", "Milieu(,,)");
+ addCMicon("bi_syma", "SymétrieAxiale(,,)");
+ addCMicon("bi_symc", "SymétrieCentrale(,,)");
+ addCMicon("bi_trans", "Translation(,,,)");
+ addCMicon("line", "Droite(,,)");
+ addCMicon("ray", "DemiDroite(,,)");
+ addCMicon("parallel", "Parallèle(,,)");
+ addCMicon("plumb", "Perpendiculaire(,,)");
+ addCMicon("bi_med", "Médiatrice(,,)");
+ addCMicon("bi_biss", "Bissectrice(,,,)");
+ addCMicon("segment", "Segment(,,)");
+ addCMicon("fixedsegment", "SegmentFixe(,,)");
+ addCMicon("vector", "Vecteur(,,)");
+ addCMicon("area", "Polygone(,)");
+ addCMicon("angle", "Angle(,,,)");
+ addCMicon("fixedangle", "AngleFixe(,,,)");
+ addCMicon("circle", "Cercle(,,)");
+ addCMicon("fixedcircle", "CercleRayon(,,)");
+ addCMicon("circle3", "Cercle3(,,,)");
+ addCMicon("bi_circ", "Cercle3pts(,,,)");
+ addCMicon("bi_arc", "Arc3pts(,,,)");
+ addCMicon("quadric", "Quadrique(,,,,,)");
+ // addCMicon("text", "");
+ addCMicon("expression", "Expression(,\"Votre expression\",,)");
+ addCMicon("text", "Texte(,\"Votre message\",,)");
+ // addCMicon("image3", "");
+ // addBlankIcon(3);
+ addCMicon("function", "FonctionCartésienne(,-5,5,\"x^2-2*x+1\")");
+ addCMicon("parametricfunction", "FonctionParamétrique(,-3.14,3.14,\"3*rcos(t)^3\",\"3*rsin(t)^3\")");
+ addCMicon("equationxy", "TracéImplicite(,\"x^3-2*x-y^2+1\")");
+ addCMicon("macro", "ExécuterMacro(,\"_x,_y,_z\")");
+ }
+ else {
+ addCMicon("point", " ⟵ Point(,,)");
+ addCMicon("intersection", " ⟵ Intersection(,,)");
+ addCMicon("midpoint", " ⟵ Milieu(,,)");
+ addCMicon("bi_syma", " ⟵ SymétrieAxiale(,,)");
+ addCMicon("bi_symc", " ⟵ SymétrieCentrale(,,)");
+ addCMicon("bi_trans", " ⟵ Translation(,,,)");
+ addCMicon("line", " ⟵ Droite(,,)");
+ addCMicon("ray", " ⟵ DemiDroite(,,)");
+ addCMicon("parallel", " ⟵ Parallèle(,,)");
+ addCMicon("plumb", " ⟵ Perpendiculaire(,,)");
+ addCMicon("bi_med", " ⟵ Médiatrice(,,)");
+ addCMicon("bi_biss", " ⟵ Bissectrice(,,,)");
+ addCMicon("segment", " ⟵ Segment(,,)");
+ addCMicon("fixedsegment", " ⟵ SegmentFixe(,,)");
+ addCMicon("vector", " ⟵ Vecteur(,,)");
+ addCMicon("area", " ⟵ Polygone(,)");
+ addCMicon("angle", " ⟵ Angle(,,,)");
+ addCMicon("fixedangle", " ⟵ AngleFixe(,,,)");
+ addCMicon("circle", " ⟵ Cercle(,,)");
+ addCMicon("fixedcircle", " ⟵ CercleRayon(