[latexdraw] 51/147: * fix conflicts from merge of 2.0.0 source
Stuart Prescott
stuart at debian.org
Thu Nov 24 23:53:26 UTC 2016
This is an automated email from the git hooks/post-receive script.
stuart pushed a commit to branch master
in repository latexdraw.
commit dc0b0a7828140384b60c639c87c9292e4cd6e695
Author: Stuart Prescott <stuart at debian.org>
Date: Tue Apr 21 17:38:06 2009 +0000
* fix conflicts from merge of 2.0.0 source
---
build.xml | 237 +-
latexDraw/ui/LaTeXDrawFrame.java | 10997 ++++++++++++++++---------------------
2 files changed, 4805 insertions(+), 6429 deletions(-)
diff --git a/build.xml b/build.xml
index 3e4f322..75587d4 100644
--- a/build.xml
+++ b/build.xml
@@ -1,117 +1,120 @@
-<?xml version="1.0"?>
-<project name="Template Buildfile" default="jar" basedir=".">
- <property name="dir.out" value="out"/>
- <property name="dir.data" value="out/data"/>
- <property name="dir.report" value="out/report"/>
- <property name="dir.doc" location="api"/>
- <property name="jar.junit" value="/opt/eclipse/plugins/org.junit4_4.3.1/junit.jar"/>
-
- <path id="classpathlib">
- <fileset dir="${lib.dir}" includes="**/*.jar"/>
- </path>
-
- <!-- Creates the output directories -->
- <target name="prepare">
- <mkdir dir="${dir.out}"/>
- <mkdir dir="${dir.report}"/>
- <mkdir dir="${dir.data}/.cache"/>
- <mkdir dir="${dir.data}/templates"/>
- </target>
-
- <target name="compile">
- <javac srcdir="latexDraw" destdir="" classpathref="classpathlib" debug="on" encoding="utf8" />
- </target>
-
- <target name="junit" description="Launches the junit tests." depends="junit check">
- <junit printsummary="on" fork="false" haltonfailure="false"
- failureproperty="tests.failed" showoutput="true">
- <formatter type="xml"/>
-
- <classpath>
- <pathelement location="" />
- <pathelement path="" />
- <pathelement path="${java.class.path}" />
- </classpath>
-
- <test name="junit.test.TestLatexDraw" haltonfailure="no" outfile="${dir.report}/TEST1">
- <formatter type="xml"/>
- </test>
- </junit>
-
- <junitreport todir="${dir.report}" >
- <fileset dir="${dir.report}">
- <include name="TEST*.xml"/>
- </fileset>
- <report format="frames" todir="${dir.report}"/>
- </junitreport>
-
- <fail if="tests.failed"></fail>
- </target>
-
- <target name="doc" depends="jar" description="Generation of the documentation.">
- <javadoc destdir="${dir.doc}" author="true" version="true" use="true"
- notree="false" nonavbar="false" noindex="false" access="private"
- classpathref="classpathlib">
- <fileset dir = "">
- <include name="**/*.java"/>
- <exclude name="**/*Test*"/>
- </fileset>
- </javadoc>
- </target>
-
-
-
- <!-- Creates the jar -->
- <target name="jar" description="Generates latexdraw.jar" depends="compile">
- <!-- copies the librairies -->
- <copy todir="${dir.data}/help/" overwrite="true" failonerror="true">
- <fileset dir="help/" />
- </copy>
-
- <jar jarfile="${dir.data}/LaTeXDraw.jar" manifest="META-INF/MANIFEST.MF">
- <!-- Creates the manifest -->
- <manifest>
- <attribute name="Main-Class" value="latexDraw.ui.LaTeXDraw"/>
- <attribute name="Class-Path" value="net.sourceforge.jiu.jar
- net.sourceforge.jlibeps.jar
- com.sun.java ./ cache .cache/ templates .templates/ help help/
- "/>
- </manifest>
-
- <!-- Filters the files -->
- <fileset dir=""
- includes="latexDraw/**/*.class ; res/**/* ; lang/**/* ; help/**/*"
- excludes="latexDraw/**/*.java"/>
- </jar>
- </target>
-
-
- <target name="junit check">
- <available property="junit.present" classname="junit.framework.TestCase" />
- </target>
-
- <target name="zip src" depends="jar">
- <zip destfile="${dir.out}/LaTeXDraw1.9.3_src.zip" compress="true">
- <fileset dir=""
- includes="**/*" excludes="site/ ; Todo.txt ; graphisme/ ; out/"/>
- </zip>
- </target>
-
- <target name="launch firefox">
- <!-- launch a web browser to view the results -->
- <exec executable="firefox" os="Linux">
- <arg value="/home/arno/latexdraw/LaTeXDraw Maintenance/out/report/index.html"/>
- </exec>
- </target>
-
-</project>
-
-
-
-
-
-
-
-
-
-
+<?xml version="1.0"?>
+<project name="Template Buildfile" default="jar" basedir=".">
+ <property name="dir.out" value="out"/>
+ <property name="dir.data" value="out/data"/>
+ <property name="dir.report" value="out/report"/>
+ <property name="dir.doc" location="doc"/>
+
+ <!-- Creates the output directories -->
+ <target name="prepare">
+ <mkdir dir="${dir.out}"/>
+ <mkdir dir="${dir.report}"/>
+ <mkdir dir="${dir.data}/.cache"/>
+ <mkdir dir="${dir.data}/templates"/>
+ </target>
+
+ <target name="compile">
+ <javac srcdir="latexDraw" destdir="" classpathref="classpathlib" debug="on" encoding="utf8" />
+ </target>
+
+ <target name="junit" description="Launches the junit tests." depends="junit check, prepare">
+ <junit printsummary="on" fork="false" haltonfailure="false"
+ failureproperty="tests.failed" showoutput="true">
+ <formatter type="xml"/>
+
+ <classpath>
+ <pathelement location="" />
+ <pathelement path="" />
+ <pathelement path="${java.class.path}" />
+ </classpath>
+
+ <batchtest todir="${dir.report}">
+ <fileset dir="" includes="junit/**/Test*.class" />
+ </batchtest>
+
+ </junit>
+
+ <junitreport todir="${dir.report}" >
+ <fileset dir="${dir.report}">
+ <include name="TEST*.xml"/>
+ </fileset>
+ <report format="frames" todir="${dir.report}"/>
+ </junitreport>
+ </target>
+
+ <target name="doc" depends="jar" description="Generation of the documentation.">
+ <javadoc destdir="${dir.doc}" author="true" version="true" use="true"
+ notree="false" nonavbar="false" noindex="false" access="private">
+ <fileset dir = "">
+ <include name="**/*.java"/>
+ <exclude name="**/*Test*"/>
+ </fileset>
+ </javadoc>
+ </target>
+
+
+
+ <!-- Creates the jar -->
+ <target name="jar" description="Generates latexdraw.jar">
+ <!-- copies the librairies -->
+ <copy todir="${dir.data}/help/" overwrite="true" failonerror="true">
+ <fileset dir="help/" />
+ </copy>
+
+ <copy todir="${dir.data}/lib/" overwrite="true" failonerror="true">
+ <fileset dir="lib/" />
+ </copy>
+
+ <copy todir="${dir.out}/" overwrite="true" failonerror="true">
+ <fileset dir="" includes="license.txt ; release_note.txt ; readme.txt ; install_vista.vbs"/>
+ </copy>
+
+ <copy todir="${dir.data}/.cache" overwrite="true" failonerror="true">
+ <fileset dir=".cache/"/>
+ </copy>
+
+ <copy todir="${dir.data}/templates" overwrite="true" failonerror="true">
+ <fileset dir="templates/"/>
+ </copy>
+
+ <jar jarfile="${dir.data}/LaTeXDraw.jar" manifest="META-INF/MANIFEST.MF">
+ <!-- Creates the manifest -->
+ <manifest>
+ <attribute name="Main-Class" value="latexDraw.ui.LaTeXDraw"/>
+ <attribute name="Class-Path" value="net.sourceforge.jiu.jar jlibeps.jar txt ./ cache .cache/ templates .templates/ help help/ "/>
+ </manifest>
+
+ <!-- Filters the files -->
+ <fileset dir=""
+ includes="latexDraw/**/*.class ; res/**/* ; lang/**/*"
+ excludes="latexDraw/**/*.java ; latexDraw/installer/* ; latexDraw/ui/listeners/InstallerListener.*"/>
+ </jar>
+ </target>
+
+
+ <target name="junit check">
+ <available property="junit.present" classname="junit.framework.TestCase" />
+ </target>
+
+ <target name="zip src" depends="jar">
+ <zip destfile="${dir.out}/LaTeXDraw2.0.0_src.zip" compress="true">
+ <fileset dir=""
+ includes="**/*" excludes="site/ ; Todo.txt ; graphisme/ ; out/"/>
+ </zip>
+ </target>
+
+ <target name="zip jar" depends="zip src">
+ <zip destfile="${dir.out}/LaTeXDraw2.0.0_bin.zip" compress="true">
+ <fileset dir="out/"
+ includes="**/*" excludes="LaTeXDraw2.0.0_src.zip ; report"/>
+ </zip>
+ </target>
+
+ <target name="launch firefox">
+ <!-- launch a web browser to view the results -->
+ <exec executable="firefox" os="Linux">
+ <arg value="out/report/overview-summary.html"/>
+ </exec>
+ </target>
+
+</project>
diff --git a/latexDraw/ui/LaTeXDrawFrame.java b/latexDraw/ui/LaTeXDrawFrame.java
index 391b9d3..0ccfdd9 100644
--- a/latexDraw/ui/LaTeXDrawFrame.java
+++ b/latexDraw/ui/LaTeXDrawFrame.java
@@ -1,6312 +1,4685 @@
-/*
- * LaTeXDrawFrame.java
- */
-
-package latexDraw.ui;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.print.PrinterJob;
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Vector;
-
-import javax.print.*;
-import javax.print.attribute.HashPrintRequestAttributeSet;
-import javax.print.attribute.PrintRequestAttributeSet;
-import javax.swing.*;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkListener;
-
-import latexDraw.exceptions.LaTeXDrawException;
-import latexDraw.figures.*;
-import latexDraw.figures.properties.Arrowable;
-import latexDraw.filters.*;
-import latexDraw.lang.LaTeXDrawLang;
-import latexDraw.parsers.pstricks.LaTeXDrawPSTricksParserActions;
-import latexDraw.parsers.pstricks.PSTricksParameters;
-import latexDraw.parsers.pstricks.PSTricksParser;
-import latexDraw.psTricks.PSTricksConstants;
-import latexDraw.ui.components.*;
-import latexDraw.ui.dialog.*;
-import latexDraw.ui.listeners.MenusListener;
-import latexDraw.ui.listeners.RecentFilesListener;
-import latexDraw.ui.listeners.ShortcutsListener;
-import latexDraw.util.LaTeXDrawPath;
-import latexDraw.util.UndoRedoManager;
-import latexDraw.util.VersionChecker;
-
-
-/**
- * This class contains all the elements of the graphic interface.<br>
- * <br>
- * This file is part of LaTeXDraw<br>
- * Copyright (c) 2005-2007 Arnaud BLOUIN<br>
- *<br>
- * LaTeXDraw 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.<br>
- *<br>
- * LaTeXDraw is distributed 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.<br>
- *
- *
- * <br>
- * 04/05/06<br>
- * @author Arnaud BLOUIN<br>
- * @version 1.9.2<br>
- */
-public final class LaTeXDrawFrame extends JFrame implements ActionListener, ItemListener, ChangeListener, Runnable
-{
- private static final long serialVersionUID = 1L;
-
- /** To change if update is needed or not. */
- public static final boolean WITH_UPDATE = false;
-
- public static final Insets INSET_BUTTON = new Insets(1,1,1,1);
-
- /** The path by default */
- public static final String DEFAULT_PATH = System.getProperty("user.home");//$NON-NLS-1$
-
- protected ShortcutsFrame shortcutsFrame;
-
- protected MenusListener menusListener;
-
- protected RecentFilesListener recentFilesListener;
-
- protected JMenuItem updateToGridMenu;
-
- /** The path of the location of the LaTeX editor. */
- private String pathTexEditor = null;
-
- /** The thread of the parser */
- private Thread parsingThread;
-
- /** The TeX parser */
- private PSTricksParser texParser;
-
- /** The code to parse (Useful for insertPSTricksCode) */
- private String codeToParse;
-
- /** The file to parse */
- private File fileToParse;
-
- private JSlider sliderDelimitor;
-
- /** This frame allows the user to insert PSTricks code in the drawing. */
- private InsertPSTricksCodeFrame insertCodeFrame;
-
- /** The panel containing the generated code*/
- private CodePanel codePanel;
-
- /** The panel containing the drawing made by the user*/
- private DrawPanel drawPanel;
-
- /** The toolbar of the application*/
- private JToolBar toolbar;
-
- /** The progress bar for the parsing */
- private JProgressBar progressBar;
-
- /** The button stop for the parsing */
- private JButton stopButton;
-
- /** The menubar of the application */
- private JMenuBar menuBar;
-
- protected JCheckBoxMenuItem menuAutoUpdate;
-
- protected JMenuItem menuReloadCode;
-
- /** The identificator of the build */
- private static final String ID_BUILD = "20071023";//$NON-NLS-1$
-
- /** The e-mail of the latexdraw developer */
- public static final String MAIL_ME = "arno_b at users.sourceforge.net"; //$NON-NLS-1$
-
- /** Allows to realize undo and redo */
- private UndoRedoManager undoManager;
-
- /** This frame allows to set the parameters of a line */
- private ParametersLineFrame paramLineFrame;
-
- /** This frame allows to set the parameters of axes. */
- private ParametersAxeFrame paramAxesFrame;
-
- /** This frame allows to set the parameters of a circle */
- private ParametersCircleSquareFrame paramCircleFrame;
-
- /** This frame allows to set the parameters of an ellipse */
- private ParametersEllipseRectangleFrame paramEllipseFrame;
-
- /** This frame allows to set the parameters of a Bézier curve */
- private ParametersBezierCurveFrame paramBezierCurveFrame;
-
- /** This frame allows to set the parameters of akin points */
- private ParametersAkinPointsFrame paramAkinPointsFrame;
-
- /** This frame allows to set the parameters of a dot */
- private ParametersDotFrame paramDotFrame;
-
- /** This frame allows to set the parameters of a text */
- private ParametersTextFrame paramTextFrame;
-
- /** This frame allows to set the parameters of a triangle */
- private ParametersTriangleFrame paramTriangleFrame;
-
-// /** This frame allows to set the parameters of a drawing */
-// private ParametersDrawFrame paramDrawFrame;
-
- /** This frame allows to set the parameters of a grid */
- private ParametersGridFrame paramGridFrame;
-
- /** This frame allows to set the parameters of a rhombus */
- private ParametersRhombusFrame paramRhombusFrame;
-
- /** This frame allows to set the parameters of an arc */
- private ParametersArcFrame paramArcFrame;
-
- /** This frame allows to set the parameters of a polygon */
- private ParametersPolygonJoinedLinesFrame paramPolygonFrame;
-
- /** This frame allows to set the parameters of several joined lines */
- private ParametersPolygonJoinedLinesFrame paramJoinedLinesFrame;
-
- /** This frame allows the user to add comments to his drawing */
- private AddCommentsFrame addCommentsFrame;
-
- /** This frame allows to set the parameters of the drawing (not the
- * Figure.Draw */
- private DrawPropertiesFrame drawPropertiesFrame;
-
- /** Allows to display a frame displaying the LaTeXDraw help */
- private JFrame helpFrame;
-
- /** The current file of the project */
- private File currentFile;
-
- /** The path used on open/save actions */
- private static String pathOpen = DEFAULT_PATH;
-
- /** The path used on exportations actions */
- private static String pathExport = DEFAULT_PATH;
-
- /** The frame which allows to convert pictures */
- public static BatchConvertFrame convertFrame;
-
- /** Allows to know if the program must check new version */
- private boolean checkNewVersion;
-
- /** The menu which allows to import templates */
- private MenuTemplate menuTemplate;
-
- /** Allows to cut a figure */
- private JMenuItem cutMenu;
-
- /** Allows to paste a figure */
- private JMenuItem pasteMenu;
-
- /** Allows to copy a figure */
- private JMenuItem copyMenu;
-
- /** This menu allows to export the drawing as a template */
- private JMenuItem exportTemplateMenu;
-
- /** Allows to undo actions */
- private JMenuItem undoMenu;
-
- /** Allows to redo actions */
- private JMenuItem redoMenu;
-
- /** This menu allows the user to export either the pstricks code
- * or the drawing as jpg picture */
- private JMenu exportAsMenu;
-
- private JMenu recentFilesMenu;
-
- /** The menu "drawing" */
- private JMenu drawMenu;
-
- /** This menu allows the user to set his preferences */
- private JMenuItem preferencesMenu;
-
- /** This menu allows the set the properties of the selected figure */
- private JMenuItem propertiesFigureMenu;
-
- /** This menu allows the user to delete a figure in the drawing. */
- private JMenuItem deleteFigure;
-
- /** This menu allows the user to see or not the borders of the drawing */
- private JCheckBoxMenuItem displayBorders;
-
- /** This menu allows the user to see or not the X-scale */
- private JCheckBoxMenuItem displayXScale;
-
- /** This menu allows the user to see or not the Y-scale */
- private JCheckBoxMenuItem displayYScale;
-
- /** This menu allows the user to see or not the grids */
- private JCheckBoxMenuItem displayGrid;
-
- private JCheckBoxMenuItem displayPersoGrid;
-
- private JSpinner persoGridGapField;
-
- /** This menu allows the user to set visible or not the code panel */
- private JCheckBoxMenuItem displayCodePanel;
-
- /** This menu allows to activate the automatic adjustment of
- * the borders of the drawing */
- private JCheckBoxMenuItem autoAdjustBorders;
-
- /** The About LaTeXDraw box */
- protected JFrame aboutTeXDraw;
-
- /** This frame allows the user to set his preferences */
- private PreferencesFrame preferencesFrame;
-
- /** Correspond to the current choice of the user (draw a line, ...). */
- private static String currentChoice;
-
- /** Corresponds to the name of the current project */
- private String projectName;
-
- /** The fileChooser for save/open actions */
- private JFileChooser fileChooserSave;
-
- /** The PictureChooser for 'insert picture' actions */
- private PictureChooser fileChooserPicture;
-
- /** The fileChooser for save/open actions */
- private ExportDialog fileChooserExport;
-
- /** The PictureChooser for import actions */
- private PictureChooser fileChooserImport;
-
- /** The name of the choice dotChoice */
- public static final String CHOICE_DOT_NAME = "dotChoice";//$NON-NLS-1$
-
- /** The name of the choice lineChoice */
- public static final String CHOICE_LINE_NAME = "lineChoice";//$NON-NLS-1$
-
- /** The name of the choice lineArrowLChoice */
- public static final String CHOICE_ARROW_LEFT_NAME = "arrowLChoice";//$NON-NLS-1$
-
- public static final String CHOICE_ARROW_RIGHT_NAME = "arrowRChoice";//$NON-NLS-1$
-
- /** The name of the extension of LaTeXDraw filenames (LaTeXDraw Project)*/
- public final static String PROJECT_EXTENSION = ".ldp"; //$NON-NLS-1$
-
- /** The name of the extension of LaTeXDraw templates */
- public static final String TEMPLATE_EXTENSION = ".ldt";//$NON-NLS-1$
-
- /** The beginning of the action command of templates */
- public static final String TEMPLATE_START_ACTION_CMD = "template_";//$NON-NLS-1$
-
- /** The name of the extension of GIF file */
- public static final String GIF_EXTENSION = ".gif";//$NON-NLS-1$
-
- /** The name of the extension of PPM file */
- public final static String PPM_EXTENSION = ".ppm";//$NON-NLS-1$
-
- /** The name of the extension of bmp file*/
- public final static String BMP_EXTENSION = ".bmp";//$NON-NLS-1$
-
- /** The name of the extension of png file */
- public final static String PNG_EXTENSION = ".png";//$NON-NLS-1$
-
- /** The name of the extension of jpg file */
- public final static String JPG_EXTENSION = ".jpg";//$NON-NLS-1$
-
- /** The name of the extension of EPS file */
- public final static String EPS_EXTENSION = ".eps";//$NON-NLS-1$
-
- /** The name of the application */
- public final static String LABEL_APP = "LaTeXDraw";//$NON-NLS-1$
-
- /** The label of the menu insert PSTricks code */
- public final static String LABEL_INSERT_CODE = LaTeXDrawLang.getString1_6("LaTeXDrawFrame.0"); //$NON-NLS-1$
-
- /** The label of the menu insert picture */
- public final static String LABEL_INSERT_PIX = LaTeXDrawLang.getString1_6("LaTeXDrawFrame.1"); //$NON-NLS-1$
-
- /** The label of the menu "convert picture" */
- public static final String LABEL_BATCH_CONVERT = LaTeXDrawLang.getString1_6("LaTeXDrawFrame.2"); //$NON-NLS-1$
-
- /** The label of the button stop */
- public final static String LABEL_STOP = LaTeXDrawLang.getString1_6("LaTeXDrawFrame.3"); //$NON-NLS-1$
-
- /** The label of the menu help */
- public final static String LABEL_HELP = LABEL_APP + LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.0"); //$NON-NLS-1$
-
- /** The label of the menu "aboutTexDraw" */
- public final static String LABEL_ABOUT = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.1")+ LABEL_APP+ " ..."; //$NON-NLS-1$//$NON-NLS-2$
-
- /** The label of the menu item drawLineMenu */
- public final static String LABEL_LINE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.2"); //$NON-NLS-1$
-
- /** The label of the menu item drawRectMenu */
- public final static String LABEL_RECT = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.3"); //$NON-NLS-1$
-
- /** The label of the menu item drawDotMenu */
- public final static String LABEL_DOT = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.4"); //$NON-NLS-1$
-
- /** The label of the menu item drawRectMenu */
- public final static String LABEL_SQUARE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.5"); //$NON-NLS-1$
-
- /** The label of the menu item drawRhombMenu */
- public final static String LABEL_RHOMBUS = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.6"); //$NON-NLS-1$
-
- /** The label of the menu item drawRhombMenu */
- public final static String LABEL_POINTS_AKIN = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.7"); //$NON-NLS-1$
-
- /** The label of the menu item drawTrianMenu */
- public final static String LABEL_TRIANGLE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.8"); //$NON-NLS-1$
-
- /** The label of the menu item drawJoinedLinesMenu */
- public final static String LABEL_JOINED_LINES = LaTeXDrawLang.getString1_6("LaTeXDrawFrame.4"); //$NON-NLS-1$
-
- /** The label of the menu item drawCircleMenu */
- public final static String LABEL_CIRCLE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.9"); //$NON-NLS-1$
-
- /** The label of the menu item drawGridMenu */
- public final static String LABEL_GRID = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.10"); //$NON-NLS-1$
-
- public final static String LABEL_AXES = LaTeXDrawLang.getString1_8("LaTeXDrawFrame.0"); //$NON-NLS-1$
-
- /** The label of the menu item drawEllipseMenu */
- public final static String LABEL_ELLIPSE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.11"); //$NON-NLS-1$
-
- /** The label of the menu item drawPolyMenu */
- public final static String LABEL_POLY = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.12"); //$NON-NLS-1$
-
- /** The label of the menu item selectFigure */
- public final static String LABEL_SELECT_FIGURE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.13"); //$NON-NLS-1$
-
- /** The label of the menu item displayBorders */
- public final static String LABEL_DISPLAY_BORDERS = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.14"); //$NON-NLS-1$
-
- /** The label of the menu item displayBorders */
- public final static String LABEL_AUTO_ADJUST_BORDERS = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.15"); //$NON-NLS-1$
-
- /** The label of the menu export as */
- public final static String LABEL_EXPORT_AS = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.16"); //$NON-NLS-1$
-
- /** The label of the menu import */
- public final static String LABEL_IMPORT = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.229"); //$NON-NLS-1$
-
- /** The label of the menu item "import from TeX file" */
- public static final String LABEL_IMPORT_TEX = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.230"); //$NON-NLS-1$
-
- /** The label of the menu item deleteFigure */
- public final static String LABEL_DELETE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.17"); //$NON-NLS-1$
-
- /** The label of the menu item which allows the user to quit the application*/
- public final static String LABEL_QUIT = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.18"); //$NON-NLS-1$
-
- /** The label of the exportCodeMenu item */
- public final static String LABEL_EXPORT_TRICKS = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.19"); //$NON-NLS-1$
-
- /** The label of the exportAsPNMFile item */
- public final static String LABEL_EXPORT_PPM = LaTeXDrawLang.getString1_6("LaTeXDrawFrame.5"); //$NON-NLS-1$
-
- /** The label of the exportAsBMPFile item */
- public final static String LABEL_EXPORT_BMP = LaTeXDrawLang.getString1_6("LaTeXDrawFrame.6"); //$NON-NLS-1$
-
- /** The label of the exportAsPNGFile item */
- public final static String LABEL_EXPORT_PNG = LaTeXDrawLang.getString1_6("LaTeXDrawFrame.7"); //$NON-NLS-1$
-
- /** The label of the export as Palm OS picture item */
- public final static String LABEL_EXPORT_PALM = LaTeXDrawLang.getString1_6("LaTeXDrawFrame.8"); //$NON-NLS-1$
-
- /** The label of the exportDrawMenu item */
- public final static String LABEL_EXPORT_JPG = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.20"); //$NON-NLS-1$
-
- /** The label of the exportEPSMenu item */
- public final static String LABEL_EXPORT_EPS = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.21"); //$NON-NLS-1$
-
- /** The label of the menuItem redoMenu */
- public final static String LABEL_REDO = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.22"); //$NON-NLS-1$
-
- /** The label of the menuItem undoMenu */
- public final static String LABEL_UNDO = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.23"); //$NON-NLS-1$
-
- /** The name of the thickness field */
- public final static String NAME_THICKNESS_FIELD = "thicknessField"; //$NON-NLS-1$
-
- public final static String NAME_DOT_SIZE_FIELD = "dotSizeField"; //$NON-NLS-1$
-
- /** The label of the saveMenu item */
- public final static String LABEL_SAVE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.25"); //$NON-NLS-1$
-
- /** The label of the saveAsMenu item */
- public final static String LABEL_SAVE_AS = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.26"); //$NON-NLS-1$
-
- public final static String LABEL_RECENT_FILES = LaTeXDrawLang.getString1_9("LaTeXDrawFrame.0"); //$NON-NLS-1$
-
- /** The label of the openMenu item */
- public final static String LABEL_OPEN = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.27"); //$NON-NLS-1$
-
- /** The label of the newMenu item */
- public final static String LABEL_NEW = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.28"); //$NON-NLS-1$
-
- /** The label of the printCodeMenu item */
- public final static String LABEL_PRINT_CODE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.29"); //$NON-NLS-1$
-
- /** The label of the printDrawMenu item */
- public final static String LABEL_PRINT_DRAW = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.30"); //$NON-NLS-1$
-
- /** The label of the ImageButton behindSel */
- public static final String LABEL_BEHIND_SEL = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.31"); //$NON-NLS-1$
-
- /** The label of the ImageButton inFrontOfSel */
- public static final String LABEL_FRONT_SEL = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.32"); //$NON-NLS-1$
-
- /** The label of the button join */
- public static final String LABEL_JOIN = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.33"); //$NON-NLS-1$
-
- /** The label of the button separate */
- public static final String LABEL_SEPARATE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.34"); //$NON-NLS-1$
-
- /** The label of the arcMenu item */
- public final static String LABEL_ARC = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.35"); //$NON-NLS-1$
-
- /** The label of the wedgeMenu item */
- public final static String LABEL_WEDGE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.36"); //$NON-NLS-1$
-
- /** The label of the chordMenu item */
- public final static String LABEL_CHORD = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.37"); //$NON-NLS-1$
-
- /** The version of the application */
- public final static String VERSION = "1.9.5";//$NON-NLS-1$
-
- /** The label of the menuItem displayXScale */
- public static final String LABEL_DISPLAY_XSCALE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.38"); //$NON-NLS-1$
-
- /** The label of the menuItem Y */
- public static final String LABEL_DISPLAY_YSCALE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.39"); //$NON-NLS-1$
-
- /** The label of the menu copy */
- public static final String LABEL_COPY = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.40"); //$NON-NLS-1$
-
- /** The label of the menuItem updateTemplates */
- public static final String LABEL_TEMPLATE_UPDATE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.41"); //$NON-NLS-1$
-
- /** The label of the menuItem exportAsTemplate */
- public static final String LABEL_TEMPLATE_EXPORT = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.42"); //$NON-NLS-1$
-
- /** The label of the menu paste */
- public static final String LABEL_PASTE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.43"); //$NON-NLS-1$
-
- /** The label of the menu cut */
- public static final String LABEL_CUT = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.44"); //$NON-NLS-1$
-
- public static final String LABEL_DISPLAY_PERSO_GRID = LaTeXDrawLang.getString1_8("LaTeXDrawFrame.1"); //$NON-NLS-1$
-
- /** The label of the menuItem displayGrid */
- public static final String LABEL_DISPLAY_GRID = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.45"); //$NON-NLS-1$
-
- /** The label of the menuItem codePanel */
- public static final String LABEL_DISPLAY_CODE_PANEL = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.46"); //$NON-NLS-1$
-
- /** The label of the JButton buttonBordersColor */
- public static final String LABEL_COLOR_BUTTON = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.47"); //$NON-NLS-1$
-
- /** The label of the JButton buttonInteriorColor */
- public static final String LABEL_COLOR_INTERIOR_BUTTON = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.48"); //$NON-NLS-1$
-
- /** The label of the JButton buttonHatchColor */
- public static final String LABEL_COLOR_HATCH = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.49"); //$NON-NLS-1$
-
- /** The label of the JButton buttonDbleBoundColor */
- public static final String LABEL_COLOR_DBLE_BOUND = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.50"); //$NON-NLS-1$
-
- /** The label of the JButton buttonShadowColor. */
- public static final String LABEL_COLOR_SHADOW = LaTeXDrawLang.getString1_7("LaTeXDrawFrame.0"); //$NON-NLS-1$
-
- /** The label of the JCheckBox @see filledCheckBox */
- public static final String LABEL_FILLED_CHECKBOX = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.51"); //$NON-NLS-1$
-
- /** The label of the JCheckBox @see dbleBoundCheckBox */
- public static final String LABEL_DBLE_BOUND_CHECKBOX = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.52"); //$NON-NLS-1$
-
- /** The label of the button which allows to choose the first colour of a gradient. */
- public static final String LABEL_COLOR_GRADIENT_FIRST = LaTeXDrawLang.getString1_7("LaTeXDrawFrame.1"); //$NON-NLS-1$
-
- /** The label of the button which allows to choose the second colour of a gradient. */
- public static final String LABEL_COLOR_GRADIENT_SECOND = LaTeXDrawLang.getString1_7("LaTeXDrawFrame.2"); //$NON-NLS-1$
-
- /** The label of the JCheckBox shadowCheckBox. */
- public static final String LABEL_SHADOW_CHECKBOX = LaTeXDrawLang.getString1_7("LaTeXDrawFrame.3"); //$NON-NLS-1$
-
- /** The label of the menu properties of the selected figure*/
- public static final String LABEL_FIGURE_PROPERTIES = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.53"); //$NON-NLS-1$
-
- /** The label of the menu properties of the drawing*/
- public static final String LABEL_DRAW_PROPERTIES = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.54"); //$NON-NLS-1$
-
- /** The label of the menu "addCommentsMenu" */
- public static final String LABEL_COMMENTS = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.55"); //$NON-NLS-1$
-
- /** The label of the menuItem "preferencesMenu" */
- public static final String LABEL_PREFERENCES = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.56"); //$NON-NLS-1$
-
- /** The label of the menuItem zoomIn */
- public static final String LABEL_ZOOM_IN = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.57"); //$NON-NLS-1$
-
- /** The label of the menuItem zoomOut */
- public static final String LABEL_ZOOM_OUT = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.58"); //$NON-NLS-1$
-
- public static final String LABEL_MAGNETIC_CB = "MagneticCB";//$NON-NLS-1$
-
- public static final String LABEL_PERSO_GRID_GAP_FIELD = "PersoGridGapFD";//$NON-NLS-1$
-
- /** Allows to know if by default the grid must be displayed */
- public static final boolean DEFAULT_DISPLAY_GRID = false;
-
- /** Allows to know if by default the XScale must be displayed */
- public static final boolean DEFAULT_DISPLAY_XSCALE = true;
-
- /** Allows to know if by default the YScaleC must be displayed */
- public static final boolean DEFAULT_DISPLAY_YSCALE = true;
-
- /** Allows to know if by default the codePane must be displayed */
- public static final boolean DEFAULT_DISPLAY_CODEPANEL = true;
-
- /** Allows to know if by default the borders of the drawing must be displayed */
- public static final boolean DEFAULT_DISPLAY_BORDERS = false;
-
- /** Allows to know if by default the program must check new version on start-up */
- public static final boolean DEFAULT_CHECK_VERSION = true;
-
- /** This token allows the program to identify LaTeXDraw template files */
- public static final String TOKEN_TEMPLATE_FILE = "LaTeXDraw template"; //$NON-NLS-1$
-
- public static final String LABEL_TEX_EDITOR = "texEditor";//$NON-NLS-1$
-
- /** The label of the menuItem menuText */
- public static final String LABEL_TEXT = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.60"); //$NON-NLS-1$
-
- /** The label of the menus which allow to put a figure in the foreground */
- public static final String LABEL_FOREGROUND = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.61"); //$NON-NLS-1$
-
- /** The label of the menus which allow to put a figure in the background */
- public static final String LABEL_BACKGROUND = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.62"); //$NON-NLS-1$
-
- /** The label of the menuItem "bézier curve" */
- public static final String LABEL_BEZIER_CURVE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.63"); //$NON-NLS-1$
-
- public static final String LABEL_CLOSED_BEZIER_CURVE = LaTeXDrawLang.getString1_9("LaTeXDrawFrame.1"); //$NON-NLS-1$
-
- /** Allows the user the zoom at 100 % */
- public static final String LABEL_ZOOM_DEFAULT = "Zoom 100%"; //$NON-NLS-1$
-
- /** The label of the button which allow to rotate a figure with the mouse */
- public static final String LABEL_ROTATE = LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.64"); //$NON-NLS-1$
-
- public static final String LABEL_ROTATE_90 = "rotation90"; //$NON-NLS-1$
-
- public static final String LABEL_ROTATE_180 = "rotation180"; //$NON-NLS-1$
-
- public static final String LABEL_ROTATE_270 = "rotation270"; //$NON-NLS-1$
-
- public static final String LABEL_MIRROR_H = "mirrorH"; //$NON-NLS-1$
-
- public static final String LABEL_MIRROR_V = "mirrorV"; //$NON-NLS-1$
-
- public static final String NAME_SLIDER_DELIMITOR = "sliderDel";//$NON-NLS-1$
-
- /** The splitpane of the program */
- protected JSplitPane splitPane;
-
- /** The field which allows to change the thickness of figures */
- private JSpinner thicknessField;
-
- /** Allows to set the colour of the borders of a figure */
- private ColorButton buttonBordersColor;
-
- /** Allows the attribute "filled" in Figure class */
- private JCheckBox filledCheckBox;
-
- /** Set/unset a shadow to a figure. */
- private JCheckBox shadowCheckBox;
-
- /** Allows have double boundaries on a figure */
- private JCheckBox dbleBoundCheckBox;
-
- /** Allows to set the colour of the interior of a figure */
- private ColorButton buttonInteriorColor;
-
- /** Allows to set the colour of the shadow of a figure */
- private ColorButton buttonShadowColor;
-
- /** Allows to change the colour of the hatch */
- private ColorButton buttonHatchColor;
-
- /** Contains buttons allowing to rotate figures. */
- private ListJToggleButton rotationButtons;
-
- /** Contains the buttons allowing to return figures (mirrors). */
- private ListJToggleButton mirrorButtons;
-
- /** Allows to select the type of the dot */
- private LaTeXDrawComboBox dotChoice;
-
- /** Allows to select the position of the borders of the figure (if possible) */
- private LaTeXDrawComboBox bordersPositionChoice;
-
- /** Allows to change the colour of the space between the double boundaries */
- private ColorButton buttonDbleBoundColor;
-
- /** This button allows to join several figures */
- private JButton joinButton;
-
- /** This button allows to separate several figures */
- private JButton separateButton;
-
- /** This button allows to copy the generated code when the code panel is closed. */
- private JButton copyCodeButton;
-
- /** Allows to change the style of the left-end of the line */
- private LaTeXDrawComboBox lineArrowLChoice;
-
- /** Allows to change the style of the right-end of the line */
- private LaTeXDrawComboBox lineArrowRChoice;
-
- /** Allows to change the style of the line */
- private LaTeXDrawComboBox lineChoice;
-
- /** Allows to change the style of hatch */
- private LaTeXDrawComboBox hatchChoice;
-
- /** Allows to choose the first colour of a gradient. */
- private ColorButton buttonGradientStartC;
-
- /** Allows to choose the second colour of a gradient. */
- private ColorButton buttonGradientEndC;
-
- /** The former location of the divider location (used to show or
- * hide the codepanel) */
- private int formerDividerLocation;
-
- /** The button of the menubar to draw polygons */
- public JRadioButtonMenuItem menuPoly;
-
- /** The button of the menubar to draw lines */
- public JRadioButtonMenuItem menuLine;
-
- /** The button of the menubar to draw rectangles */
- public JRadioButtonMenuItem menuRect;
-
- /** The button of the menubar to draw squares */
- public JRadioButtonMenuItem menuSquare;
-
- /** The button of the menubar to draw dots */
- public JRadioButtonMenuItem menuDot;
-
- /** The button of the menubar to draw rhombus */
- public JRadioButtonMenuItem menuRhombus;
-
- /** The button of the menubar to draw triangles */
- public JRadioButtonMenuItem menuTriangle;
-
- /** The button of the menubar to draw joined lines */
- public JRadioButtonMenuItem menuJoinedLines;
-
- /** The button of the menubar to draw circles */
- public JRadioButtonMenuItem menuCircle;
-
- public JRadioButtonMenuItem menuAxes;
-
- /** The button of the menubar to draw chords */
- public JRadioButtonMenuItem menuChord;
-
- /** The button of the menubar to draw ellipses */
- public JRadioButtonMenuItem menuEllipse;
-
- /** The button of the menubar to draw Bézier curves */
- public JRadioButtonMenuItem menuBezierCurve;
-
- public JRadioButtonMenuItem menuClosedBezierCurve;
-
- /** The button of the menubar to select figures */
- public JRadioButtonMenuItem menuSelect;
-
- /** The button of the menubar to draw arcs */
- public JRadioButtonMenuItem menuArc;
-
- /** The button of the menubar to draw wedges */
- public JRadioButtonMenuItem menuWedge;
-
- /** The button of the menubar to draw texts */
- public JRadioButtonMenuItem menuText;
-
- /** The button of the menubar to draw akin points */
- public JRadioButtonMenuItem menuPointsAkin;
-
- /** The button of the menubar to draw grids */
- public JRadioButtonMenuItem menuGrid;
-
- /* The buttons of the toolbar */
- public JToggleButton buttonImageLine;
- public JToggleButton buttonImageDot;
- public JToggleButton buttonImageRect;
- public JToggleButton buttonImageSquare;
- public JToggleButton buttonImageRhombus;
- public JToggleButton buttonImageTriangle;
- public JToggleButton buttonImageEllipse;
- public JToggleButton buttonImageCircle;
- public JToggleButton buttonImageSelect;
- public JToggleButton buttonImageBorders;
- public JToggleButton buttonImageWedge;
- public JToggleButton buttonImageChord;
- public JToggleButton buttonImageArc;
- public JToggleButton buttonImagePoly;
- public JToggleButton buttonImageText;
- public JToggleButton buttonImagePointsAkin;
- public JToggleButton buttonImageGrid;
- public JToggleButton buttonImageAxes;
- public JToggleButton buttonImageBezierCurve;
- public JToggleButton buttonImageClosedBezierCurve;
- public JToggleButton buttonImageJoinedLines;
- public JButton buttonImageDel;
- public JButton buttonImageProperties;
- public JButton buttonImageRedo;
- public JButton buttonImageUndo;
- private ListJToggleButton locationButtons;
-
- /** The version of the LaTeXDraw file loaded */
- private static String versionOfFile = "";//$NON-NLS-1$
-
- /** The X-scale of the drawing */
- private XScale xScale;
-
- /** The Y-scale of the drawing */
- private YScale yScale;
-
- private static ImageIcon bezierCurveIcon; private static ImageIcon chordIcon;
- private static ImageIcon newIcon; public static ImageIcon lineStyleNoneIcon;
- private static ImageIcon openIcon; public static ImageIcon lineStyleDashedIcon;
- private static ImageIcon saveIcon ; public static ImageIcon lineStyleDottedIcon;
- private static ImageIcon saveAsIcon; public static ImageIcon dotStyleNoneIcon;
- private static ImageIcon circleIcon; public static ImageIcon dotStyleSquareIcon;
- private static ImageIcon delIcon; public static ImageIcon dotStyleSquareFIcon;
- private static ImageIcon dotIcon; public static ImageIcon dotStylePentagonIcon;
- private static ImageIcon ellipseIcon; public static ImageIcon dotStylePentagonFIcon;
- private static ImageIcon emptyIcon; public static ImageIcon dotStyleTriangleIcon;
- private static ImageIcon lineIcon; public static ImageIcon dotStyleTriangleFIcon;
- private static ImageIcon rectIcon; public static ImageIcon dotStyleBarIcon;
- private static ImageIcon rhombusIcon; public static ImageIcon dotStyleAsteriskIcon;
- private static ImageIcon selectIcon; public static ImageIcon dotStyleCrossIcon;
- private static ImageIcon squareIcon; public static ImageIcon dotStyleDiamondIcon;
- private static ImageIcon triangleIcon; public static ImageIcon dotStyleDiamondFIcon;
- private static ImageIcon propertiesIcon; public static ImageIcon dotStyleOIcon;
- private static ImageIcon printCodeIcon; public static ImageIcon dotStyleOPlusIcon;
- private static ImageIcon printDrawIcon; public static ImageIcon dotStyleOCrossIcon;
- private static ImageIcon bordersIcon; public static ImageIcon dotStylePlusIcon;
- private static ImageIcon autoBordersIcon; public static ImageIcon arrowStyleArcLIcon;
- private static ImageIcon exportIcon; public static ImageIcon arrowStyleArcRIcon;
- public static ImageIcon arrowStyleArcRRIcon; public static ImageIcon arrowStyleArcLRIcon;
- private static ImageIcon aboutIcon; public static ImageIcon arrowStyleArrowLIcon;
- private static ImageIcon helpIcon; public static ImageIcon arrowStyleArrowRIcon;
- private static ImageIcon preferencesIcon; public static ImageIcon arrowStyleBarEndLIcon;
- private static ImageIcon folderIcon; public static ImageIcon arrowStyleBarEndRIcon;
- private static ImageIcon arcIcon; public static ImageIcon arrowStyleBarInLIcon;
- private static ImageIcon wedgeIcon; public static ImageIcon arrowStyleBarInRIcon;
- private static ImageIcon zoomInIcon; public static ImageIcon arrowStyleBrackLIcon;
- public static ImageIcon arrowStyleBrackLRIcon; public static ImageIcon arrowStyleBrackRRIcon;
- private static ImageIcon zoomOutIcon; public static ImageIcon arrowStyleBrackRIcon;
- private static ImageIcon zoomDefaultIcon; public static ImageIcon arrowStyleCircleEndLIcon;
- private static ImageIcon undoIcon; public static ImageIcon arrowStyleCircleEndRIcon;
- private static ImageIcon redoIcon; public static ImageIcon arrowStyleCircleInLIcon;
- private static ImageIcon backgroundIcon; public static ImageIcon arrowStyleCircleInRIcon;
- private static ImageIcon foregroundIcon; public static ImageIcon arrowStyleDbleArrowLIcon;
- private static ImageIcon behindSelIcon; public static ImageIcon arrowStyleDbleArrowRIcon;
- private static ImageIcon inFrontOfSelIcon; public static ImageIcon arrowStyleDiskEndLIcon;
- private static ImageIcon rotateIcon; public static ImageIcon arrowStyleDiskEndRIcon;
- private static ImageIcon polygonIcon; public static ImageIcon arrowStyleDiskInLIcon;
- private static ImageIcon textIcon; public static ImageIcon arrowStyleDiskInRIcon;
- private static ImageIcon pointsAkinIcon; public static ImageIcon arrowStyleNoneLIcon;
- public static ImageIcon arrowStyleNoneRIcon; public static ImageIcon arrowStyleRDbleArrowLIcon;
- public static ImageIcon arrowStyleRDbleArrowRIcon; public static ImageIcon arrowStyleRArrowLIcon;
- public static ImageIcon arrowStyleRArrowRIcon; public static ImageIcon copyIcon;
- protected static ImageIcon pasteIcon; public static ImageIcon cutIcon;
- public static ImageIcon arrowStyleRoundInLIcon; public static ImageIcon arrowStyleRoundInRIcon;
- public static ImageIcon sendIcon; public static ImageIcon hatchNoneIcon;
- public static ImageIcon hatchHorizIcon; public static ImageIcon hatchVertIcon;
- public static ImageIcon hatchCrossIcon; protected static ImageIcon gridIcon;
- protected static ImageIcon joinIcon; protected static ImageIcon separateIcon;
- private static ImageIcon middleIcon; private static ImageIcon innerIcon;
- private static ImageIcon outerIcon; public static ImageIcon copySelIcon;
- private static ImageIcon importIcon; protected static ImageIcon commentIcon;
- private static ImageIcon joinedLinesIcon; public static ImageIcon batchConvertIcon;
- public static ImageIcon okIcon; public static ImageIcon errIcon;
- public static ImageIcon minusIcon; public static ImageIcon plusIcon;
- public static ImageIcon stopIcon; private static ImageIcon reloadIcon;
- private static ImageIcon insertPicIcon; private static ImageIcon insertPSTricksIcon;
- private static ImageIcon thicknessIcon; public static ImageIcon gradientIcon;
- private static ImageIcon displayGridIcon; private static ImageIcon rotate270Icon;
- private static ImageIcon rotate180Icon; private static ImageIcon rotate90Icon;
- private static ImageIcon mirrorVIcon; private static ImageIcon mirrorHIcon;
- protected static ImageIcon axesIcon; private static ImageIcon texEditorIcon;
- private static ImageIcon delimitorIcon; private static ImageIcon curvesFreehandIcon;
- private static ImageIcon linesFreehandIcon; private static ImageIcon closeLineIcon;
- private static ImageIcon closeCurveIcon; protected static ImageIcon closedBezierIcon;
-
- /** This label is behind the field thickness in the paramsToolbar */
- private JLabel labelThickness;
-
- /** The older version of java that this program can used */
- public static final String VERSION_MIN = "1.5"; //$NON-NLS-1$
-
- /** This attribute is used to save the value of the "updateCode" checkBox
- * of the code panel when we hide to code panel (we disactivate the auto-update when to code panel is hidden */
- private boolean formerIsInAutoUpdate;
-
- /** The status-bar of the frame */
- private JTextField statusBar;
-
- /** Allows to know if the grid is magnetic or not. */
- private JCheckBox magneticCB;
-
- /** The look and feel of the program. */
- private String lookAndFeel;
-
- protected ShortcutsListener shortcutsListener;
-
- protected JToggleButton rotateButton;
-
-
- /* Save of the general parameters. */
- protected ColorButton genGradientEndCB;
- protected ColorButton genGradientStartCB;
- protected ColorButton genLineCB;
- protected ColorButton genInteriorCB;
- protected ColorButton genDbleBordCB;
- protected ColorButton genHatchCB;
- protected ColorButton genShadowCB;
- protected Color genGradientEndC;
- protected Color genGradientStartC;
- protected Color genLineC;
- protected Color genInteriorC;
- protected Color genDbleC;
- protected Color genHatchC;
- protected Color genShadowC;
- protected float genThickness;
- protected float genDotSize;
- protected boolean genIsFilled;
- protected boolean genHasDbleBord;
- protected boolean genHasShadow;
- protected String genHatchS;
- protected String genDotS;
- protected String genLineStyleS;
- protected String genLeftArrS;
- protected String genRightArrS;
- protected String genBordPosS;
- protected ListJToggleButton genColorL;
-
- protected JSpinner dotSizeField;
- protected JLabel labelDotSize;
-
-
-
- /** The constructor by default. */
- public LaTeXDrawFrame(String[] args, boolean splash)
- {
- LaTeXDrawPath.checkDirectories();
-
- try
- {
- lookAndFeel = PreferencesFrame.readTheme();
- UIManager.setLookAndFeel(lookAndFeel);
- }catch(Exception ex) { /* Dommage ! */ }
-
- SplashScreen splashScreen = new SplashScreen(lookAndFeel);
-
- if(splash)
- splashScreen.setVisible(true);
-
- /* Only 1.5 and newer version of java can launch this program. */
- try
- {
- if(System.getProperty("java.version").compareTo(VERSION_MIN)< 0)//$NON-NLS-1$
- throw new LaTeXDrawException(LaTeXDrawException.INVALID_JAVA_VERSION);
-
- Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
- setLocation(0,0);
- setSize(dim.width/3*2, dim.height/3*2);
- splashScreen.addToProgressBar(5);
- statusBar = new JTextField("");//$NON-NLS-1$
- statusBar.setEditable(false);
-
- progressBar = new JProgressBar();
- progressBar.setMaximumSize(new Dimension(300, 20));
- progressBar.setPreferredSize(new Dimension(300, 20));
- progressBar.setVisible(false);
-
- menusListener = new MenusListener(this);
-
- loadResources();
- splashScreen.addToProgressBar(10);
- convertFrame = new BatchConvertFrame();
- splashScreen.addToProgressBar(5);
- Image i = Toolkit.getDefaultToolkit().getImage(
- getClass().getClassLoader().getResource("res/LaTeXDrawIcon.png"));//$NON-NLS-1$
- setIconImage(i);
-
- if(dim.height<100 || dim.width<100)
- throw new LaTeXDrawException(LaTeXDrawException.INVALID_SCREEN_SIZE);
-
- checkNewVersion = DEFAULT_CHECK_VERSION && WITH_UPDATE;
- codePanel = new CodePanel(this);
- codePanel.setVisible(DEFAULT_DISPLAY_CODEPANEL);
- splashScreen.addToProgressBar(5);
- DrawContainer draw = new DrawContainer(DEFAULT_DISPLAY_BORDERS);
- splashScreen.addToProgressBar(10);
- drawPanel = new DrawPanel(draw, codePanel, this);
- splashScreen.addToProgressBar(5);
-
- JPanel paramsToolbar = new JPanel(new FlowLayout(FlowLayout.LEFT));
- JPanel p= new JPanel();
-
- projectName = null;
- fileChooserSave = null;
- fileChooserExport = null;
- currentFile = null;
-
- splashScreen.addToProgressBar(5);
- createMenuBar();
- splashScreen.addToProgressBar(10);
- createToolbar();
- splashScreen.addToProgressBar(10);
-
- undoManager = new UndoRedoManager(draw.getFigures(), draw, this);
- splashScreen.addToProgressBar(5);
-
- yScale = new YScale(drawPanel, xScale);
- yScale.setVisible(DEFAULT_DISPLAY_YSCALE);
- xScale = new XScale(drawPanel, yScale);
- yScale.setXScale(xScale);
- xScale.setVisible(DEFAULT_DISPLAY_XSCALE);
-
- p.setLayout(new BorderLayout());
- p.add(yScale, BorderLayout.WEST);
- p.add(xScale, BorderLayout.NORTH);
- p.add(drawPanel, BorderLayout.CENTER);
- setJMenuBar(menuBar);
- updateUndoRedo();
- splashScreen.addToProgressBar(10);
-
- splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, p, codePanel);
- splitPane.setContinuousLayout(true);
- splitPane.setOneTouchExpandable(true);
- splitPane.setDividerSize(6);
- formerDividerLocation = (int)(dim.width*0.7);
- splitPane.setDividerLocation(formerDividerLocation);
-
- getContentPane().setLayout(new BorderLayout());
- getContentPane().add(toolbar, BorderLayout.NORTH);
- getContentPane().add(splitPane, BorderLayout.CENTER);
-
- addCommentsFrame = new AddCommentsFrame(this);
-
- SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_THICKNESS,0.1,1000,0.1);
- thicknessField = new JSpinner(model);
- thicknessField.setEditor(new JSpinner.NumberEditor(thicknessField, "0.0"));//$NON-NLS-1$
- thicknessField.addChangeListener(this);
- thicknessField.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.65")); //$NON-NLS-1$
- thicknessField.setName(NAME_THICKNESS_FIELD);
- thicknessField.setMaximumSize(new Dimension(55, 30));
- thicknessField.setMinimumSize(new Dimension(55, 30));
- thicknessField.setPreferredSize(new Dimension(55, 30));
-
- model = new SpinnerNumberModel(Dot.DEFAULT_WIDTH,0.1,1000,0.1);
- dotSizeField = new JSpinner(model);
- dotSizeField.setEditor(new JSpinner.NumberEditor(dotSizeField, "0.0"));//$NON-NLS-1$
- dotSizeField.addChangeListener(this);
- dotSizeField.setToolTipText("Define the size of a dot.");
- dotSizeField.setName(NAME_DOT_SIZE_FIELD);
- dotSizeField.setMaximumSize(new Dimension(55, 30));
- dotSizeField.setMinimumSize(new Dimension(55, 30));
- dotSizeField.setPreferredSize(new Dimension(55, 30));
- labelDotSize = new JLabel(dotStyleNoneIcon);
-
- buttonBordersColor = new ColorButton(LABEL_COLOR_BUTTON, new ButtonIcon(Color.BLACK));
- buttonBordersColor.setMargin(INSET_BUTTON);
- buttonBordersColor.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.66")); //$NON-NLS-1$
- buttonBordersColor.setActionCommand(LABEL_COLOR_BUTTON);
- buttonBordersColor.addActionListener(this);
- genLineCB = new ColorButton(LABEL_COLOR_BUTTON, new ButtonIcon(Color.BLACK));
- genLineCB.setMargin(INSET_BUTTON);
- genLineCB.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.66")); //$NON-NLS-1$
- genLineCB.setActionCommand(LABEL_COLOR_BUTTON);
- genLineCB.addActionListener(this);
-
- filledCheckBox = new JCheckBox(LABEL_FILLED_CHECKBOX);
- filledCheckBox.setMargin(LaTeXDrawFrame.INSET_BUTTON);
- filledCheckBox.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.67")); //$NON-NLS-1$
- filledCheckBox.setActionCommand(LABEL_FILLED_CHECKBOX);
- filledCheckBox.addActionListener(this);
-
- buttonInteriorColor = new ColorButton(LABEL_COLOR_INTERIOR_BUTTON, new ButtonIcon(Figure.DEFAULT_INTERIOR_COL));
- buttonInteriorColor.setMargin(INSET_BUTTON);
- buttonInteriorColor.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.68")); //$NON-NLS-1$
- buttonInteriorColor.setActionCommand(LABEL_COLOR_INTERIOR_BUTTON);
- buttonInteriorColor.addActionListener(this);
- genInteriorCB = new ColorButton(LABEL_COLOR_INTERIOR_BUTTON, new ButtonIcon(Figure.DEFAULT_INTERIOR_COL));
- genInteriorCB.setMargin(INSET_BUTTON);
- genInteriorCB.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.68")); //$NON-NLS-1$
- genInteriorCB.setActionCommand(LABEL_COLOR_INTERIOR_BUTTON);
- genInteriorCB.addActionListener(this);
-
- buttonHatchColor = new ColorButton(LABEL_COLOR_HATCH, new ButtonIcon(Figure.DEFAULT_BORDERS_COL));
- buttonHatchColor.setMargin(INSET_BUTTON);
- buttonHatchColor.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.69")); //$NON-NLS-1$
- buttonHatchColor.setActionCommand(LABEL_COLOR_HATCH);
- buttonHatchColor.addActionListener(this);
- genHatchCB = new ColorButton(LABEL_COLOR_HATCH, new ButtonIcon(Figure.DEFAULT_BORDERS_COL));
- genHatchCB.setMargin(INSET_BUTTON);
- genHatchCB.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.69")); //$NON-NLS-1$
- genHatchCB.setActionCommand(LABEL_COLOR_HATCH);
- genHatchCB.addActionListener(this);
-
- dotChoice = Dot.createDotStyleChoice();
- dotChoice.setName(CHOICE_DOT_NAME);
- dotChoice.addItemListener(this);
- dotChoice.setPreferredSize(new Dimension(55,30));
- dotChoice.setMaximumSize(new Dimension(55,30));
-
- lineChoice = Figure.createStyleLineChoice();
- lineChoice.setName(CHOICE_LINE_NAME);
- lineChoice.addItemListener(this);
- lineChoice.setPreferredSize(new Dimension(70,30));
- lineChoice.setMaximumSize(new Dimension(70,30));
-
- hatchChoice = Figure.createFillChoice();
- hatchChoice.addItemListener(this);
- hatchChoice.setPreferredSize(new Dimension(65,30));
- hatchChoice.setMaximumSize(new Dimension(65,30));
-
- lineArrowLChoice = ArrowHead.createLeftArrowStyleList();
- lineArrowLChoice.setName(CHOICE_ARROW_LEFT_NAME);
- lineArrowLChoice.addItemListener(this);
- lineArrowLChoice.setPreferredSize(new Dimension(80,30));
- lineArrowLChoice.setMaximumSize(new Dimension(80,30));
-
- lineArrowRChoice = ArrowHead.createRightArrowStyleList();
- lineArrowRChoice.setName(CHOICE_ARROW_RIGHT_NAME);
- lineArrowRChoice.addItemListener(this);
- lineArrowRChoice.setPreferredSize(new Dimension(80,30));
- lineArrowRChoice.setMaximumSize(new Dimension(80,30));
- splashScreen.addToProgressBar(5);
- JButton buttonImageForeground = new JButton(foregroundIcon);
- buttonImageForeground.setMargin(INSET_BUTTON);
- buttonImageForeground.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.70")); //$NON-NLS-1$
- buttonImageForeground.addActionListener(this);
- buttonImageForeground.setActionCommand(LABEL_FOREGROUND);
-
- JButton buttonImageBackground = new JButton(backgroundIcon);
- buttonImageBackground.setMargin(INSET_BUTTON);
- buttonImageBackground.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.71")); //$NON-NLS-1$
- buttonImageBackground.addActionListener(this);
- buttonImageBackground.setActionCommand(LABEL_BACKGROUND);
-
- JButton buttonImageFront = new JButton(inFrontOfSelIcon);
- buttonImageFront.setMargin(INSET_BUTTON);
- buttonImageFront.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.72")); //$NON-NLS-1$
- buttonImageFront.addActionListener(this);
- buttonImageFront.setActionCommand(LABEL_FRONT_SEL);
-
- JButton buttonImageBehind = new JButton(behindSelIcon);
- buttonImageBehind.setMargin(INSET_BUTTON);
- buttonImageBehind.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.73")); //$NON-NLS-1$
- buttonImageBehind.addActionListener(this);
- buttonImageBehind.setActionCommand(LABEL_BEHIND_SEL);
-
- rotationButtons = new ListJToggleButton(this, rotateIcon, ListJToggleButton.LOCATION_NORTH);
- rotationButtons.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.2")); //$NON-NLS-1$
-
- rotateButton = new JToggleButton(rotateIcon);
- rotateButton.setMargin(INSET_BUTTON);
- rotateButton.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.74")); //$NON-NLS-1$
- rotateButton.addActionListener(this);
- rotateButton.setActionCommand(LABEL_ROTATE);
-
- JButton rotate90Button = new JButton(rotate90Icon);
- rotate90Button.setMargin(INSET_BUTTON);
- rotate90Button.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.3")); //$NON-NLS-1$
- rotate90Button.addActionListener(this);
- rotate90Button.setActionCommand(LABEL_ROTATE_90);
-
- JButton rotate180Button = new JButton(rotate180Icon);
- rotate180Button.setMargin(INSET_BUTTON);
- rotate180Button.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.4")); //$NON-NLS-1$
- rotate180Button.addActionListener(this);
- rotate180Button.setActionCommand(LABEL_ROTATE_180);
-
- JButton rotate270Button = new JButton(rotate270Icon);
- rotate270Button.setMargin(INSET_BUTTON);
- rotate270Button.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.5")); //$NON-NLS-1$
- rotate270Button.addActionListener(this);
- rotate270Button.setActionCommand(LABEL_ROTATE_270);
-
- rotationButtons.addComponent(rotateButton);
- rotationButtons.addComponent(rotate90Button);
- rotationButtons.addComponent(rotate180Button);
- rotationButtons.addComponent(rotate270Button);
- rotationButtons.addSeparator();
-
- mirrorButtons = new ListJToggleButton(this, mirrorHIcon, ListJToggleButton.LOCATION_NORTH);
- mirrorButtons.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.6")); //$NON-NLS-1$
-
- JButton mirrorHB = new JButton(mirrorHIcon);
- mirrorHB.setMargin(INSET_BUTTON);
- mirrorHB.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.7")); //$NON-NLS-1$
- mirrorHB.addActionListener(this);
- mirrorHB.setActionCommand(LABEL_MIRROR_H);
-
- JButton mirrorVB = new JButton(mirrorVIcon);
- mirrorVB.setMargin(INSET_BUTTON);
- mirrorVB.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.8")); //$NON-NLS-1$
- mirrorVB.addActionListener(this);
- mirrorVB.setActionCommand(LABEL_MIRROR_V);
- splashScreen.addToProgressBar(5);
- mirrorButtons.addComponent(mirrorHB);
- mirrorButtons.addComponent(mirrorVB);
- mirrorButtons.addSeparator();
-
- joinButton = new JButton(joinIcon);
- joinButton.setMargin(INSET_BUTTON);
- joinButton.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.75")); //$NON-NLS-1$
- joinButton.addActionListener(this);
- joinButton.setActionCommand(LABEL_JOIN);
-
- separateButton = new JButton(separateIcon);
- separateButton.setMargin(INSET_BUTTON);
- separateButton.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.76")); //$NON-NLS-1$
- separateButton.addActionListener(this);
- separateButton.setActionCommand(LABEL_SEPARATE);
-
- bordersPositionChoice = Figure.createBordersPositionChoice();
- bordersPositionChoice.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.77")); //$NON-NLS-1$
- bordersPositionChoice.addItemListener(this);
- bordersPositionChoice.setPreferredSize(new Dimension(45,30));
- bordersPositionChoice.setMaximumSize(new Dimension(45,30));
-
- dbleBoundCheckBox = new JCheckBox(LABEL_DBLE_BOUND_CHECKBOX);
- dbleBoundCheckBox.setMargin(INSET_BUTTON);
- dbleBoundCheckBox.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.78")); //$NON-NLS-1$
- dbleBoundCheckBox.setActionCommand(LABEL_DBLE_BOUND_CHECKBOX);
- dbleBoundCheckBox.addActionListener(this);
-
- buttonDbleBoundColor = new ColorButton(LABEL_DBLE_BOUND_CHECKBOX, new ButtonIcon(Figure.DEFAULT_DOUBLE_COLOR));
- buttonDbleBoundColor.setMargin(INSET_BUTTON);
- buttonDbleBoundColor.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.79")); //$NON-NLS-1$
- buttonDbleBoundColor.setActionCommand(LABEL_COLOR_DBLE_BOUND);
- buttonDbleBoundColor.addActionListener(this);
- genDbleBordCB = new ColorButton(LABEL_DBLE_BOUND_CHECKBOX, new ButtonIcon(Figure.DEFAULT_DOUBLE_COLOR));
- genDbleBordCB.setMargin(INSET_BUTTON);
- genDbleBordCB.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.79")); //$NON-NLS-1$
- genDbleBordCB.setActionCommand(LABEL_COLOR_DBLE_BOUND);
- genDbleBordCB.addActionListener(this);
-
- stopButton = new JButton(stopIcon);
- stopButton.setMargin(INSET_BUTTON);
- stopButton.setActionCommand(LABEL_STOP);
- stopButton.addActionListener(this);
- stopButton.setName(LABEL_STOP);
- stopButton.setToolTipText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.9")); //$NON-NLS-1$
- stopButton.setVisible(false);
-
- shadowCheckBox = new JCheckBox(LABEL_SHADOW_CHECKBOX);
- shadowCheckBox.setMargin(INSET_BUTTON);
- shadowCheckBox.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.4")); //$NON-NLS-1$
- shadowCheckBox.setActionCommand(LABEL_SHADOW_CHECKBOX);
- shadowCheckBox.addActionListener(this);
-
- buttonShadowColor = new ColorButton(LABEL_COLOR_SHADOW, new ButtonIcon(Figure.DEFAULT_SHADOW_COLOR));
- buttonShadowColor.setMargin(INSET_BUTTON);
- buttonShadowColor.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.5")); //$NON-NLS-1$
- buttonShadowColor.setActionCommand(LABEL_COLOR_SHADOW);
- buttonShadowColor.addActionListener(this);
- genShadowCB = new ColorButton(LABEL_COLOR_SHADOW, new ButtonIcon(Figure.DEFAULT_SHADOW_COLOR));
- genShadowCB.setMargin(INSET_BUTTON);
- genShadowCB.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.5")); //$NON-NLS-1$
- genShadowCB.setActionCommand(LABEL_COLOR_SHADOW);
- genShadowCB.addActionListener(this);
-
- labelThickness = new JLabel(thicknessIcon);
- locationButtons = new ListJToggleButton(this, foregroundIcon, ListJToggleButton.LOCATION_NORTH);
- locationButtons.addComponent(buttonImageForeground);
- locationButtons.addComponent(buttonImageBackground);
- locationButtons.addComponent(buttonImageFront);
- locationButtons.addComponent(buttonImageBehind);
- locationButtons.addSeparator();
- locationButtons.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.6")); //$NON-NLS-1$
-
- buttonGradientStartC = new ColorButton(LABEL_COLOR_GRADIENT_FIRST, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR));
- buttonGradientStartC.setMargin(INSET_BUTTON);
- buttonGradientStartC.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.7")); //$NON-NLS-1$
- buttonGradientStartC.setActionCommand(LABEL_COLOR_GRADIENT_FIRST);
- buttonGradientStartC.addActionListener(this);
- genGradientStartCB = new ColorButton(LABEL_COLOR_GRADIENT_FIRST, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR));
- genGradientStartCB.setMargin(INSET_BUTTON);
- genGradientStartCB.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.7")); //$NON-NLS-1$
- genGradientStartCB.setActionCommand(LABEL_COLOR_GRADIENT_FIRST);
- genGradientStartCB.addActionListener(this);
-
- buttonGradientEndC = new ColorButton(LABEL_COLOR_GRADIENT_SECOND, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR));
- buttonGradientEndC.setMargin(INSET_BUTTON);
- buttonGradientEndC.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.8")); //$NON-NLS-1$
- buttonGradientEndC.setActionCommand(LABEL_COLOR_GRADIENT_SECOND);
- buttonGradientEndC.addActionListener(this);
- genGradientEndCB = new ColorButton(LABEL_COLOR_GRADIENT_SECOND, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR));
- genGradientEndCB.setMargin(INSET_BUTTON);
- genGradientEndCB.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.8")); //$NON-NLS-1$
- genGradientEndCB.setActionCommand(LABEL_COLOR_GRADIENT_SECOND);
- genGradientEndCB.addActionListener(this);
- splashScreen.addToProgressBar(5);
-
- initializeGeneralFields();
- genColorL = new ListJToggleButton(this, "Colours", ListJToggleButton.LOCATION_NORTH);
- genColorL.addComponent(genLineCB);
- genColorL.addComponent(genInteriorCB);
- genColorL.addComponent(genHatchCB);
- genColorL.addComponent(genDbleBordCB);
- genColorL.addComponent(genShadowCB);
- genColorL.addComponent(genGradientStartCB);
- genColorL.addComponent(genGradientEndCB);
-
- paramsToolbar.add(progressBar);
- paramsToolbar.add(stopButton);
- paramsToolbar.add(rotationButtons);
- paramsToolbar.add(locationButtons);
- paramsToolbar.add(mirrorButtons);
- paramsToolbar.add(joinButton);
- paramsToolbar.add(separateButton);
- paramsToolbar.add(labelThickness);
- paramsToolbar.add(thicknessField);
- paramsToolbar.add(labelDotSize);
- paramsToolbar.add(dotSizeField);
- paramsToolbar.add(genColorL);
- paramsToolbar.add(buttonBordersColor);
- paramsToolbar.add(filledCheckBox);
- paramsToolbar.add(buttonInteriorColor);
- paramsToolbar.add(hatchChoice);
- paramsToolbar.add(buttonGradientStartC);
- paramsToolbar.add(buttonGradientEndC);
- paramsToolbar.add(buttonHatchColor);
- paramsToolbar.add(dotChoice);
- paramsToolbar.add(lineChoice);
- paramsToolbar.add(lineArrowLChoice);
- paramsToolbar.add(lineArrowRChoice);
- paramsToolbar.add(bordersPositionChoice);
- paramsToolbar.add(dbleBoundCheckBox);
- paramsToolbar.add(buttonDbleBoundColor);
- paramsToolbar.add(shadowCheckBox);
- paramsToolbar.add(buttonShadowColor);
-
- JPanel southPanel = new JPanel();
- southPanel.setLayout(new BorderLayout());
- southPanel.add(paramsToolbar, BorderLayout.CENTER);
- southPanel.add(statusBar, BorderLayout.SOUTH);
- getContentPane().add(southPanel, BorderLayout.SOUTH);
- splashScreen.addToProgressBar(5);
- preferencesFrame = new PreferencesFrame(draw, this);
- formerIsInAutoUpdate = preferencesFrame.isCodeInAutoUpdate();
- convertFrame.setPathSelect(pathOpen);
- convertFrame.setPathOutput(pathExport);
- codePanel.setIsInAutoUpdate(formerIsInAutoUpdate);
- recentFilesListener = new RecentFilesListener(preferencesFrame, this);
- shortcutsListener = new ShortcutsListener(this);
- addKeyListener(shortcutsListener);
-
- try{drawPanel.isSelection(false);}
- catch(Exception ex)
- {
- ex.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ex);
- }
-
- setTitle(LABEL_APP);
-
- setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
-
- addWindowListener(
- new WindowAdapter()
- {
- @Override
- public void windowClosing(WindowEvent e)
- {
- onWindowClosing();
- }
- });
-
- setCurrentChoice(LABEL_SELECT_FIGURE);
- setSelection(false);
-
- boolean fileIsOk = true;
- /* Management of command line */
- if(args.length>0)
- {
- if(args.length>1)
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.81")); //$NON-NLS-1$
- if(!open(args[0], false))
- fileIsOk = false;
- }
-
- updateRecentFilesMenu();
- drawPanel.setIsModified(false);
- splashScreen.addToProgressBar(5);
-
- if(checkNewVersion && WITH_UPDATE)
- {
- VersionChecker vc = new VersionChecker(this);
- vc.start();
- }
-
- splashScreen.setVisible(false);
-
- if(System.getProperty("os.name").toLowerCase().compareTo("linux")==0)
- setVisible(true);
- setExtendedState(Frame.MAXIMIZED_BOTH);
-
- if(!fileIsOk)
- JOptionPane.showMessageDialog(this, "Impossible to open the file.",
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.194"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
-
- }
- catch(Exception e1)
- {
- splashScreen.setVisible(false);
- JOptionPane.showMessageDialog(this, LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.82") + //$NON-NLS-1$
- e1.toString(), LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.83"), //$NON-NLS-1$
- JOptionPane.WARNING_MESSAGE);
- e1.printStackTrace();
- LaTeXDrawFrame.this.windowClosed();
- }
- }
-
-
-
- /**
- * Create the menu item of the menu "recent files".
- * @since 1.9
- */
- public void updateRecentFilesMenu()
- {
- Vector<String> recentFilesName = preferencesFrame.getRecentFilesName();
- recentFilesMenu.removeAll();
-
- for(String fileName : recentFilesName)
- {
- String shortName = fileName.substring(fileName.lastIndexOf(System.getProperty("file.separator"))+1);//$NON-NLS-1$
- JMenuItem menuItem = new JMenuItem(shortName);
- menuItem.setToolTipText(fileName);
- menuItem.addActionListener(recentFilesListener);
- menuItem.setActionCommand(RecentFilesListener.RECENT_PREFIX_CMD+fileName);
- recentFilesMenu.add(menuItem);
- }
-
- recentFilesMenu.addSeparator();
- JMenuItem delMenu = new JMenuItem(LaTeXDrawLang.getString1_9("LaTeXDrawFrame.2"), delIcon); //$NON-NLS-1$
- delMenu.setActionCommand(RecentFilesListener.ACTION_CMD_RECENT_CLEAR);
- delMenu.addActionListener(recentFilesListener);
- recentFilesMenu.add(delMenu);
- }
-
-
-
- /**
- * @return Returns the versionOfFile.
- */
- public static String getVersionOfFile()
- {
- return versionOfFile;
- }
-
-
-
-
- /**
- * Defines actions to do on window closing
- */
- public void onWindowClosing()
- {
- try
- {
- if(drawPanel.isModified())
- {
- int id = dialogConfirmSave();
-
- switch(id)
- {
- case JOptionPane.YES_OPTION :
- if(save(false))
- LaTeXDrawFrame.this.windowClosed();
- break;
- case JOptionPane.NO_OPTION :
- LaTeXDrawFrame.this.windowClosed();
- break;
- case JOptionPane.CANCEL_OPTION : return;
- default : return;
- }
- }
- else LaTeXDrawFrame.this.windowClosed();
- }catch(Exception ex)
- {
- ex.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ex);
- }
- }
-
-
-
-
- /**
- * Allows to load a image icon from a path
- * @param path The path
- * @return The image icon
- */
- public ImageIcon loadImageIcon(String path)
- {
- URL url;
-
- try
- {
- url = getClass().getResource(path);
- if(url==null)
- throw new MalformedURLException();
- return new ImageIcon(url);
- }catch(Exception e)
- {
- e.printStackTrace();
- JOptionPane.showMessageDialog(this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.84") + //$NON-NLS-1$
- e.toString()+"<br>"+path+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.85"),//$NON-NLS-1$ //$NON-NLS-2$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.86"), //$NON-NLS-1$
- JOptionPane.WARNING_MESSAGE);
- return null;
- }
- }
-
-
-
-
- /**
- * Allows to load some resources like icons
- */
- private void loadResources()
- {
- hatchNoneIcon = loadImageIcon("/res/hatch/hatch.none.png");//$NON-NLS-1$
- hatchVertIcon = loadImageIcon("/res/hatch/hatch.vert.png");//$NON-NLS-1$
- hatchHorizIcon = loadImageIcon("/res/hatch/hatch.horiz.png");//$NON-NLS-1$
- hatchCrossIcon = loadImageIcon("/res/hatch/hatch.cross.png");//$NON-NLS-1$
-
- arrowStyleArcLIcon = loadImageIcon("/res/arrowStyles/line.arc.left.png");//$NON-NLS-1$
- arrowStyleArcRIcon = loadImageIcon("/res/arrowStyles/line.arc.right.png");//$NON-NLS-1$
- arrowStyleArcLRIcon = loadImageIcon("/res/arrowStyles/line.arc.r.left.png");//$NON-NLS-1$
- arrowStyleArcRRIcon = loadImageIcon("/res/arrowStyles/line.arc.r.right.png");//$NON-NLS-1$
- arrowStyleArrowLIcon = loadImageIcon("/res/arrowStyles/line.arrow.left.png");//$NON-NLS-1$
- arrowStyleArrowRIcon = loadImageIcon("/res/arrowStyles/line.arrow.right.png");//$NON-NLS-1$
- arrowStyleBarEndLIcon = loadImageIcon("/res/arrowStyles/line.barEnd.left.png");//$NON-NLS-1$
- arrowStyleBarEndRIcon = loadImageIcon("/res/arrowStyles/line.barEnd.right.png");//$NON-NLS-1$
- arrowStyleBarInLIcon = loadImageIcon("/res/arrowStyles/line.barIn.left.png");//$NON-NLS-1$
- arrowStyleBarInRIcon = loadImageIcon("/res/arrowStyles/line.barIn.right.png");//$NON-NLS-1$
- arrowStyleBrackLIcon = loadImageIcon("/res/arrowStyles/line.bracket.left.png");//$NON-NLS-1$
- arrowStyleBrackRIcon = loadImageIcon("/res/arrowStyles/line.bracket.right.png");//$NON-NLS-1$
- arrowStyleBrackLRIcon = loadImageIcon("/res/arrowStyles/line.bracket.r.left.png");//$NON-NLS-1$
- arrowStyleBrackRRIcon = loadImageIcon("/res/arrowStyles/line.bracket.r.right.png");//$NON-NLS-1$
- arrowStyleCircleEndLIcon = loadImageIcon("/res/arrowStyles/line.circle.end.left.png");//$NON-NLS-1$
- arrowStyleCircleEndRIcon = loadImageIcon("/res/arrowStyles/line.circle.end.right.png");//$NON-NLS-1$
- arrowStyleCircleInLIcon = loadImageIcon("/res/arrowStyles/line.circle.in.left.png");//$NON-NLS-1$
- arrowStyleCircleInRIcon = loadImageIcon("/res/arrowStyles/line.circle.in.right.png");//$NON-NLS-1$
- arrowStyleDbleArrowLIcon = loadImageIcon("/res/arrowStyles/line.dbleArrow.left.png");//$NON-NLS-1$
- arrowStyleDbleArrowRIcon = loadImageIcon("/res/arrowStyles/line.dbleArrow.right.png");//$NON-NLS-1$
- arrowStyleDiskEndLIcon = loadImageIcon("/res/arrowStyles/line.disk.end.left.png");//$NON-NLS-1$
- arrowStyleDiskEndRIcon = loadImageIcon("/res/arrowStyles/line.disk.end.right.png");//$NON-NLS-1$
- arrowStyleDiskInLIcon = loadImageIcon("/res/arrowStyles/line.disk.in.left.png");//$NON-NLS-1$
- arrowStyleDiskInRIcon = loadImageIcon("/res/arrowStyles/line.disk.in.right.png");//$NON-NLS-1$
- arrowStyleNoneLIcon = loadImageIcon("/res/arrowStyles/line.none.left.png");//$NON-NLS-1$
- arrowStyleNoneRIcon = loadImageIcon("/res/arrowStyles/line.none.right.png");//$NON-NLS-1$
- arrowStyleRArrowLIcon = loadImageIcon("/res/arrowStyles/line.rarrow.left.png");//$NON-NLS-1$
- arrowStyleRArrowRIcon = loadImageIcon("/res/arrowStyles/line.rarrow.right.png");//$NON-NLS-1$
- arrowStyleRDbleArrowLIcon = loadImageIcon("/res/arrowStyles/line.rdbleArrow.left.png");//$NON-NLS-1$
- arrowStyleRDbleArrowRIcon = loadImageIcon("/res/arrowStyles/line.rdbleArrow.right.png");//$NON-NLS-1$
- arrowStyleRoundInLIcon = loadImageIcon("/res/arrowStyles/line.roundIn.left.png");//$NON-NLS-1$
- arrowStyleRoundInRIcon = loadImageIcon("/res/arrowStyles/line.roundIn.right.png");//$NON-NLS-1$
-
- dotStyleAsteriskIcon = loadImageIcon("/res/dotStyles/dot.asterisk.png");//$NON-NLS-1$
- dotStyleNoneIcon = loadImageIcon("/res/dotStyles/dot.none.png");//$NON-NLS-1$
- dotStyleBarIcon = loadImageIcon("/res/dotStyles/dot.bar.png");//$NON-NLS-1$
- dotStyleOIcon = loadImageIcon("/res/dotStyles/dot.o.png");//$NON-NLS-1$
- dotStyleCrossIcon = loadImageIcon("/res/dotStyles/dot.cross.png");//$NON-NLS-1$
- dotStyleDiamondIcon = loadImageIcon("/res/dotStyles/dot.diamond.png");//$NON-NLS-1$
- dotStyleDiamondFIcon = loadImageIcon("/res/dotStyles/dot.diamondF.png");//$NON-NLS-1$
- dotStyleOCrossIcon = loadImageIcon("/res/dotStyles/dot.ocross.png");//$NON-NLS-1$
- dotStyleOPlusIcon = loadImageIcon("/res/dotStyles/dot.oplus.png");//$NON-NLS-1$
- dotStylePentagonIcon = loadImageIcon("/res/dotStyles/dot.pentagon.png");//$NON-NLS-1$
- dotStylePentagonFIcon = loadImageIcon("/res/dotStyles/dot.pentagonF.png");//$NON-NLS-1$
- dotStylePlusIcon = loadImageIcon("/res/dotStyles/dot.plus.png");//$NON-NLS-1$
- dotStyleSquareIcon = loadImageIcon("/res/dotStyles/dot.square.png");//$NON-NLS-1$
- dotStyleSquareFIcon = loadImageIcon("/res/dotStyles/dot.squareF.png");//$NON-NLS-1$
- dotStyleTriangleIcon = loadImageIcon("/res/dotStyles/dot.triangle.png");//$NON-NLS-1$
- dotStyleTriangleFIcon = loadImageIcon("/res/dotStyles/dot.triangleF.png");//$NON-NLS-1$
-
- lineStyleNoneIcon = loadImageIcon("/res/lineStyles/lineStyle.none.png");//$NON-NLS-1$
- lineStyleDashedIcon = loadImageIcon("/res/lineStyles/lineStyle.dashed.png");//$NON-NLS-1$
- lineStyleDottedIcon = loadImageIcon("/res/lineStyles/lineStyle.dotted.png");//$NON-NLS-1$
-
- middleIcon = loadImageIcon("/res/doubleBoundary/double.boundary.middle.png");//$NON-NLS-1$
- innerIcon = loadImageIcon("/res/doubleBoundary/double.boundary.inner.png");//$NON-NLS-1$
- outerIcon = loadImageIcon("/res/doubleBoundary/double.boundary.outer.png");//$NON-NLS-1$
-
- gridIcon = loadImageIcon("/res/grid.png");//$NON-NLS-1$
- copyIcon = loadImageIcon("/res/Copy.png");//$NON-NLS-1$
- pasteIcon = loadImageIcon("/res/Paste.png");//$NON-NLS-1$
- cutIcon = loadImageIcon("/res/Cut.png");//$NON-NLS-1$
- pointsAkinIcon = loadImageIcon("/res/Draw.png"); //$NON-NLS-1$
- textIcon = loadImageIcon("/res/text.png"); //$NON-NLS-1$
- polygonIcon = loadImageIcon("/res/polygon.png"); //$NON-NLS-1$
- rotateIcon = loadImageIcon("/res/rotation.png"); //$NON-NLS-1$
- inFrontOfSelIcon= loadImageIcon("/res/InFrontSelect.png"); //$NON-NLS-1$
- behindSelIcon = loadImageIcon("/res/behindSelect.png"); //$NON-NLS-1$
- backgroundIcon = loadImageIcon("/res/background.png"); //$NON-NLS-1$
- foregroundIcon = loadImageIcon("/res/foreground.png");//$NON-NLS-1$
- undoIcon = loadImageIcon("/res/Undo.png");//$NON-NLS-1$
- redoIcon = loadImageIcon("/res/Redo.png"); //$NON-NLS-1$
- zoomDefaultIcon = loadImageIcon("/res/Magnify.png"); //$NON-NLS-1$
- zoomInIcon = loadImageIcon("/res/MagnifyPlus.png"); //$NON-NLS-1$
- zoomOutIcon = loadImageIcon("/res/MagnifyMinus.png");//$NON-NLS-1$
- wedgeIcon = loadImageIcon("/res/wedge.png");//$NON-NLS-1$
- arcIcon = loadImageIcon("/res/Arc.png"); //$NON-NLS-1$
- folderIcon = loadImageIcon("/res/DocFromFolder.gif"); //$NON-NLS-1$
- preferencesIcon = loadImageIcon("/res/Hammer.gif"); //$NON-NLS-1$
- newIcon = loadImageIcon("/res/New.png"); //$NON-NLS-1$
- openIcon = loadImageIcon("/res/DocumentOut.gif"); //$NON-NLS-1$
- saveIcon = loadImageIcon("/res/DocumentIn.gif"); //$NON-NLS-1$
- saveAsIcon = loadImageIcon("/res/DocumentInAs.gif");//$NON-NLS-1$
- circleIcon = loadImageIcon("/res/circle.png"); //$NON-NLS-1$
- delIcon = loadImageIcon("/res/del.png"); //$NON-NLS-1$
- dotIcon = loadImageIcon("/res/dot.png"); //$NON-NLS-1$
- ellipseIcon = loadImageIcon("/res/ellipse.png");//$NON-NLS-1$
- emptyIcon = loadImageIcon("/res/empty.png"); //$NON-NLS-1$
- lineIcon = loadImageIcon("/res/line.png"); //$NON-NLS-1$
- rectIcon = loadImageIcon("/res/rectangle.png"); //$NON-NLS-1$
- rhombusIcon = loadImageIcon("/res/rhombus.png");//$NON-NLS-1$
- selectIcon = loadImageIcon("/res/select.png"); //$NON-NLS-1$
- squareIcon = loadImageIcon("/res/square.png"); //$NON-NLS-1$
- triangleIcon = loadImageIcon("/res/triangle.png");//$NON-NLS-1$
- propertiesIcon = loadImageIcon("/res/Palette.gif"); //$NON-NLS-1$
- printCodeIcon = loadImageIcon("/res/PrintCode.png");//$NON-NLS-1$
- printDrawIcon = loadImageIcon("/res/PrintDraw.png");//$NON-NLS-1$
- bordersIcon = loadImageIcon("/res/Object.gif"); //$NON-NLS-1$
- helpIcon = loadImageIcon("/res/help3.gif"); //$NON-NLS-1$
- aboutIcon = loadImageIcon("/res/Inform.gif"); //$NON-NLS-1$
- autoBordersIcon = loadImageIcon("/res/AutoBorders.png");//$NON-NLS-1$
- exportIcon = loadImageIcon("/res/enter.gif");//$NON-NLS-1$
- sendIcon = loadImageIcon("/res/EnvelopeIn.gif");//$NON-NLS-1$
- joinIcon = loadImageIcon("/res/join.png");//$NON-NLS-1$
- separateIcon = loadImageIcon("/res/separate.png");//$NON-NLS-1$
- reloadIcon = loadImageIcon("/res/reload.png");//$NON-NLS-1$
- bezierCurveIcon = loadImageIcon("/res/bezierCurve.png");//$NON-NLS-1$
- chordIcon = loadImageIcon("/res/chord.png"); //$NON-NLS-1$
- copySelIcon = loadImageIcon("/res/CopySel.png"); //$NON-NLS-1$
- importIcon = loadImageIcon("/res/import.gif"); //$NON-NLS-1$
- commentIcon = loadImageIcon("/res/comment.gif"); //$NON-NLS-1$
- joinedLinesIcon = loadImageIcon("/res/joinedLines.png"); //$NON-NLS-1$
- batchConvertIcon= loadImageIcon("/res/batchConvert.gif"); //$NON-NLS-1$
- okIcon = loadImageIcon("/res/ok.png"); //$NON-NLS-1$
- errIcon = loadImageIcon("/res/err.png"); //$NON-NLS-1$
- plusIcon = loadImageIcon("/res/Plus.gif"); //$NON-NLS-1$
- minusIcon = loadImageIcon("/res/Minus.gif"); //$NON-NLS-1$
- stopIcon = loadImageIcon("/res/stop.png"); //$NON-NLS-1$
- insertPicIcon = loadImageIcon("/res/timeseriesDisplay.gif"); //$NON-NLS-1$
- insertPSTricksIcon = loadImageIcon("/res/InitProject.gif"); //$NON-NLS-1$
- thicknessIcon = loadImageIcon("/res/thickness.png"); //$NON-NLS-1$
- gradientIcon = loadImageIcon("/res/hatch/gradient.png"); //$NON-NLS-1$
- displayGridIcon = loadImageIcon("/res/displayGrid.png"); //$NON-NLS-1$
- rotate180Icon = loadImageIcon("/res/rotation180.png"); //$NON-NLS-1$
- rotate90Icon = loadImageIcon("/res/rotation90.png"); //$NON-NLS-1$
- rotate270Icon = loadImageIcon("/res/rotation270.png"); //$NON-NLS-1$
- mirrorHIcon = loadImageIcon("/res/mirrorH.png"); //$NON-NLS-1$
- mirrorVIcon = loadImageIcon("/res/mirrorV.png"); //$NON-NLS-1$
- axesIcon = loadImageIcon("/res/axes.png"); //$NON-NLS-1$
- texEditorIcon = loadImageIcon("/res/texEditor.png"); //$NON-NLS-1$
- delimitorIcon = loadImageIcon("/res/delimitor.png"); //$NON-NLS-1$
- curvesFreehandIcon = loadImageIcon("/res/freehand/curve.png"); //$NON-NLS-1$
- linesFreehandIcon = loadImageIcon("/res/freehand/line.png"); //$NON-NLS-1$
- closeCurveIcon = loadImageIcon("/res/BezierCurves/closeCurve.png"); //$NON-NLS-1$
- closeLineIcon = loadImageIcon("/res/BezierCurves/closeLine.png"); //$NON-NLS-1$
- closedBezierIcon = loadImageIcon("/res/closedBezier.png"); //$NON-NLS-1$
- }
-
-
- /** Allows to get the icon "zoomIn" */
- public static ImageIcon getZoomInIcon() { return zoomInIcon; }
- /** Allows to get the icon "zoomOut" */
- public static ImageIcon getZoomOutIcon() { return zoomOutIcon; }
- /** Allows to get the icon "zoomDefault" */
- public static ImageIcon getZoomDefaultIcon() { return zoomDefaultIcon; }
- /** Allows to get the icon "new" */
- public static ImageIcon getNewIcon() { return newIcon; }
- /** Allows to get the icon "open" */
- public static ImageIcon getOpenIcon() { return openIcon; }
- /** Allows to get the icon "save" */
- public static ImageIcon getSaveIcon() { return saveIcon; }
- /** Allows to get the icon "saveAs" */
- public static ImageIcon getSaveAsIcon() { return saveAsIcon; }
- /** Allows to get the icon "circle" */
- public static ImageIcon getCircleIcon() { return circleIcon; }
- /** Allows to get the icon "del" */
- public static ImageIcon getDelIcon() { return delIcon; }
- /** Allows to get the icon "dot" */
- public static ImageIcon getDotIcon() { return dotIcon; }
- /** Allows to get the icon "ellipse" */
- public static ImageIcon getEllipseIcon() { return ellipseIcon; }
- /** Allows to get the icon "empty" */
- public static ImageIcon getEmptyIcon() { return emptyIcon; }
- /** Allows to get the icon "line" */
- public static ImageIcon getLineIcon() { return lineIcon; }
- /** Allows to get the icon "rectangle" */
- public static ImageIcon getRectIcon() { return rectIcon; }
- /** Allows to get the icon "rhombus" */
- public static ImageIcon getRhombusIcon() { return rhombusIcon; }
- /** Allows to get the icon "select" */
- public static ImageIcon getSelectIcon() { return selectIcon; }
- /** Allows to get the icon "square" */
- public static ImageIcon getSquareIcon() { return squareIcon; }
- /** Allows to get the icon "triangl" */
- public static ImageIcon getTriangleIcon() { return triangleIcon; }
- /** Allows to get the icon "properties" */
- public static ImageIcon getPropertiesIcon() { return propertiesIcon; }
- /** Allows to get the icon "printcode" */
- public static ImageIcon getPrintCodeIcon() { return printCodeIcon; }
- /** Allows to get the icon "printdraw" */
- public static ImageIcon getPrintDrawIcon() { return printDrawIcon; }
- /** Allows to get the icon "borders" */
- public static ImageIcon getBordersIcon() { return bordersIcon; }
- /** Allows to get the icon "export" */
- public static ImageIcon getExportIcon() { return exportIcon; }
- /** Allows to get the icon "about" */
- public static ImageIcon getAboutIcon() { return aboutIcon; }
- /** @return Returns the bezierCurveIcon. */
- public static ImageIcon getBezierCurveIcon(){ return bezierCurveIcon;}
- /** @return Returns the innerIcon. */
- public static ImageIcon getInnerIcon() { return innerIcon; }
- /** @return Returns the outerIcon. */
- public static ImageIcon getOuterIcon() { return outerIcon; }
- /** @return Returns the middleIcon. */
- public static ImageIcon getMiddleIcon(){ return middleIcon; }
- /** Allows to get the icon "help" */
- public static ImageIcon getHelpIcon() { return helpIcon; }
- /** Allows to get the icon "autoBorders" */
- public static ImageIcon getAutoBordersIcon(){ return autoBordersIcon;}
- /** Allows to get the icon "folder" */
- public static ImageIcon getFolderIcon() { return folderIcon; }
- /** Allows to get the icon "arc" */
- public static ImageIcon getArcIcon() { return arcIcon; }
- /** Allows to get the icon "wedge" */
- public static ImageIcon getWedgeIcon() { return wedgeIcon; }
- /** Allows to get the icon "foreground" */
- public static ImageIcon getForegroundIcon() { return foregroundIcon; }
- /** Allows to get the icon "background" */
- public static ImageIcon getBackgroundIcon() { return backgroundIcon; }
- /** Allows to get the icon "background" */
- public static ImageIcon getPolyIcon() { return polygonIcon; }
- /** Allows to get the icon "text" */
- public static ImageIcon getTextIcon() { return textIcon; }
- /** Allows to get the icon "pointsAkin" */
- public static ImageIcon getPointsAkinIcon() { return pointsAkinIcon; }
- /** Allows to get the icon "LineStyleNoneIcon" */
- public static ImageIcon getLineStyleNoneIcon() { return lineStyleNoneIcon; }
- /** Allows to get the icon "LineStyleDashedIcon" */
- public static ImageIcon getLineStyleDashedIcon() { return lineStyleDashedIcon; }
- /** Allows to get the icon "LineStyleDottedIcon" */
- public static ImageIcon getLineStyleDottedIcon() { return lineStyleDottedIcon; }
- /** Allows to get the icon "behindSel" */
- public static ImageIcon getBehindSelIcon() { return behindSelIcon; }
- /** Allows to get the icon "inFrontOfSelIcon" */
- public static ImageIcon getInFrontOfSelIcon() { return inFrontOfSelIcon; }
- /** Allows to get the icon "rotateIcon" */
- public static ImageIcon getRotateIcon() { return rotateIcon; }
- /** Allows to get the icon "chordIcon" */
- public static ImageIcon getChordIcon() { return chordIcon; }
- /** Allows to get the icon "joinedLinesIcon" */
- public static ImageIcon getJoinedLinesIcon() { return joinedLinesIcon; }
-
-
-
-
- /**
- * Allows to show the frame which allows to change the parameters of
- * a figure
- * @param f The figure we want to display its parameters
- */
- public void showParamFrame(Figure f, boolean deleteOnCancel)
- {
- try
- {
- if(f==null)
- return ;
-
- if(f instanceof BezierCurve)
- {
- if(paramBezierCurveFrame==null)
- paramBezierCurveFrame = new ParametersBezierCurveFrame(this, drawPanel, true);
-
- paramBezierCurveFrame.setVisible(true, f, deleteOnCancel, false);
- }else
- if(f instanceof AkinPoints)
- {
- if(paramAkinPointsFrame==null)
- paramAkinPointsFrame = new ParametersAkinPointsFrame(this, drawPanel, true);
-
- paramAkinPointsFrame.setVisible(true, f, deleteOnCancel, false);
- }else
- if(f instanceof Line)
- {
- if(paramLineFrame==null)
- paramLineFrame = new ParametersLineFrame(this, drawPanel, true);
-
- paramLineFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof Arc)
- {
- if(paramArcFrame==null)
- paramArcFrame = new ParametersArcFrame(this, drawPanel, true);
-
- paramArcFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof Axe)
- {
- if(paramAxesFrame==null)
- paramAxesFrame = new ParametersAxeFrame(this, drawPanel, true);
-
- paramAxesFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof Circle || f instanceof Square)
- {
- if(paramCircleFrame==null)
- paramCircleFrame = new ParametersCircleSquareFrame(this, drawPanel, true);
-
- paramCircleFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof Ellipse || f instanceof LaTeXDrawRectangle)
- {
- if(paramEllipseFrame==null)
- paramEllipseFrame = new ParametersEllipseRectangleFrame(this, drawPanel, true);
-
- paramEllipseFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof Dot)
- {
- if(paramDotFrame==null)
- paramDotFrame = new ParametersDotFrame(this, drawPanel, true);
-
- paramDotFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof Triangle)
- {
- if(paramTriangleFrame==null)
- paramTriangleFrame = new ParametersTriangleFrame(this, drawPanel, true);
-
- paramTriangleFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof Rhombus)
- {
- if(paramRhombusFrame==null)
- paramRhombusFrame = new ParametersRhombusFrame(this, drawPanel, true);
-
- paramRhombusFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof JoinedLines)
- {
- if(paramJoinedLinesFrame==null)
- paramJoinedLinesFrame = new ParametersPolygonJoinedLinesFrame(this, drawPanel, false, true);
-
- paramJoinedLinesFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof LaTeXDrawPolygon)
- {
- if(paramPolygonFrame==null)
- paramPolygonFrame = new ParametersPolygonJoinedLinesFrame(this, drawPanel, true, true);
-
- paramPolygonFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof Text)
- {
- if(paramTextFrame==null)
- paramTextFrame = new ParametersTextFrame(this, drawPanel, true);
-
- paramTextFrame.setVisible(true, f, deleteOnCancel, false);
- }
- else if(f instanceof Grid)
- {
- if(paramGridFrame==null)
- paramGridFrame = new ParametersGridFrame(this, drawPanel, true);
-
- paramGridFrame.setVisible(true, f, deleteOnCancel, false);
- }
-// else if(f instanceof Draw)
-// {
-// if(paramDrawFrame==null)
-// paramDrawFrame = new ParametersDrawFrame(this, drawPanel, true);
-//
-// paramDrawFrame.setVisible(true, f, deleteOnCancel, false);
-// }
-
- }catch(Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- }
-
-
-
-
- /**
- * Allows to get the undo/redo manager
- * @return The undo/redo manager
- */
- public UndoRedoManager getUndoManager()
- {
- return undoManager;
- }
-
-
-
- /**
- * Allows to set the name of the application
- */
- public void setTitle()
- {
- if(projectName==null)
- super.setTitle(LABEL_APP);
- else super.setTitle(LABEL_APP + " - " + projectName);//$NON-NLS-1$
- }
-
-
-
- /**
- * Allows to update some fields when a figure is selected or not.
- * @param onSelection True : a figure is selected.
- */
- public void setSelection(boolean onSelection)
- {
- Draw listSelected = drawPanel.getDraw().getSelected();
- boolean empty = listSelected==null || listSelected.isEmpty();
-
- exportTemplateMenu.setEnabled(onSelection && !empty);
- deleteFigure.setEnabled(onSelection && !empty);
- propertiesFigureMenu.setEnabled(onSelection && !empty);
- buttonImageProperties.setEnabled(onSelection && !empty);
- buttonImageDel.setEnabled(onSelection && !empty);
- locationButtons.setVisible(onSelection && !empty);
- rotationButtons.setVisible(onSelection && !empty);
- mirrorButtons.setVisible(onSelection && !empty);
- copyMenu.setEnabled(onSelection && !empty);
- cutMenu.setEnabled(onSelection && !empty);
-
- if(onSelection && listSelected!=null && listSelected.getNbFigures()==1 && listSelected.getFigureAt(0).isCustomizable() &&
- !(listSelected.getFigureAt(0) instanceof Draw))
- {
- buttonImageProperties.setEnabled(true);
- joinButton.setVisible(false);
- buttonBordersColor.setVisible(true);
- separateButton.setVisible(false);
-
- Figure selected = listSelected.getFigureAt(0);
-
- if(selected != null)
- {
- if(selected instanceof Dot)
- {
- dotChoice.setVisible(true);
- // A dot can always filled, or it cannot be filled.
- filledCheckBox.setVisible(false);
- buttonInteriorColor.setVisible(selected.canBeFilled());
- labelDotSize.setVisible(true);
- dotSizeField.setVisible(true);
- }
- else
- {
- labelDotSize.setVisible(false);
- dotSizeField.setVisible(false);
- dotChoice.setVisible(false);
- filledCheckBox.setVisible(selected.canBeFilled() && !selected.hasGradient());
- } //else
-
- buttonInteriorColor.setVisible(selected.canBeFilled() && (selected.isFilled() || selected.hasShadow()) &&
- !selected.hasGradient() && selected.shadowFillsShape());
- lineArrowLChoice.setVisible(selected.canHaveArrow());
- lineArrowRChoice.setVisible(selected.canHaveArrow());
- shadowCheckBox.setVisible(selected.canHaveShadow());
- buttonShadowColor.setVisible(selected.hasShadow());
- dbleBoundCheckBox.setVisible(selected.isDoubleBoundaryable());
- buttonDbleBoundColor.setVisible(dbleBoundCheckBox.isSelected());
- bordersPositionChoice.setVisible(selected.isBordersMovable());
- labelThickness.setVisible(selected.isThicknessable());
- thicknessField.setVisible(selected.isThicknessable());
- lineChoice.setVisible(selected.isDashableOrDotable());
- hatchChoice.setVisible(selected.canBeHatched());
- buttonGradientEndC.setVisible(selected.canBeHatched() && selected.hasGradient());
- buttonGradientStartC.setVisible(buttonGradientEndC.isVisible());
- buttonHatchColor.setVisible(selected.canBeHatched() && selected.isHatched());
- }
- genColorL.setVisible(false);
- }// if(onSelection)
- else
- {
- if(listSelected!=null && (listSelected.getNbFigures()!=1 || (!listSelected.getFigureAt(0).isCustomizable() &&
- !(listSelected.getFigureAt(0) instanceof Draw))))
- {
- buttonImageProperties.setEnabled(false);
- propertiesFigureMenu.setEnabled(false);
- }
-
- buttonImageProperties.setEnabled(false);
- dbleBoundCheckBox.setVisible(true);
- buttonDbleBoundColor.setVisible(false);
- bordersPositionChoice.setVisible(true);
- buttonBordersColor.setVisible(false);
- labelThickness.setVisible(true);
- buttonHatchColor.setVisible(false);
- buttonInteriorColor.setVisible(false);
- hatchChoice.setVisible(true);
- buttonHatchColor.setVisible(false);
- dotChoice.setVisible(true);
- lineChoice.setVisible(true);
- lineArrowLChoice.setVisible(true);
- lineArrowRChoice.setVisible(true);
- thicknessField.setVisible(true);
- buttonShadowColor.setVisible(false);
- shadowCheckBox.setVisible(true);
- buttonGradientEndC.setVisible(false);
- buttonGradientStartC.setVisible(false);
- filledCheckBox.setVisible(true);
- genColorL.setVisible(true);
- dotSizeField.setVisible(true);
- labelDotSize.setVisible(true);
-
- joinButton.setVisible(listSelected!=null && listSelected.getNbFigures()>1);
- separateButton.setVisible(listSelected!=null && listSelected.getNbFigures()==1 && listSelected.getFigureAt(0) instanceof Draw);
- }
-
- updateFrameFields();
- }
-
-
-
-
- /**
- * Initialise the menubar of the application.
- */
- private void createMenuBar()
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.87")); //$NON-NLS-1$
- menuBar = new JMenuBar();
- ButtonGroup drawMenuGroup = new ButtonGroup();
-
- JMenu fileMenu = new JMenu(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.88")); //$NON-NLS-1$
- JMenu editMenu = new JMenu(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.89")); //$NON-NLS-1$
- JMenu displayM = new JMenu(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.90")); //$NON-NLS-1$
- drawMenu = new JMenu(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.91")); //$NON-NLS-1$
- JMenu insertMenu = new JMenu(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.10")); //$NON-NLS-1$
- JMenu codeMenu = new JMenu(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.92")); //$NON-NLS-1$
- JMenu helpMenu = new JMenu(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.93")); //$NON-NLS-1$
- JMenuItem menu;
-
-
- undoMenu = new JMenuItem(LABEL_UNDO, KeyEvent.VK_Z);
- undoMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z,InputEvent.CTRL_MASK));
- undoMenu.setIcon(undoIcon);
- undoMenu.addActionListener(menusListener);
- undoMenu.setActionCommand(LABEL_UNDO);
- editMenu.add(undoMenu);
-
- redoMenu = new JMenuItem(LABEL_REDO, KeyEvent.VK_Y);
- redoMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y,InputEvent.CTRL_MASK));
- redoMenu.setIcon(redoIcon);
- redoMenu.addActionListener(menusListener);
- redoMenu.setActionCommand(LABEL_REDO);
- editMenu.add(redoMenu);
-
- editMenu.addSeparator();
-
- copyMenu = new JMenuItem(LABEL_COPY, KeyEvent.VK_C);
- copyMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_MASK));
- copyMenu.setIcon(copyIcon);
- copyMenu.addActionListener(menusListener);
- copyMenu.setActionCommand(LABEL_COPY);
- editMenu.add(copyMenu);
- copyMenu.setEnabled(false);
-
- cutMenu = new JMenuItem(LABEL_CUT, KeyEvent.VK_X);
- cutMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_MASK));
- cutMenu.setIcon(cutIcon);
- cutMenu.addActionListener(menusListener);
- cutMenu.setActionCommand(LABEL_CUT);
- editMenu.add(cutMenu);
- cutMenu.setEnabled(false);
-
- pasteMenu = new JMenuItem(LABEL_PASTE, KeyEvent.VK_V);
- pasteMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,InputEvent.CTRL_MASK));
- pasteMenu.setIcon(pasteIcon);
- pasteMenu.addActionListener(menusListener);
- pasteMenu.setActionCommand(LABEL_PASTE);
- editMenu.add(pasteMenu);
- pasteMenu.setEnabled(false);
-
- // Creation of the file menu
- menu = new JMenuItem(LABEL_NEW, KeyEvent.VK_N);
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,InputEvent.CTRL_MASK));
- menu.setIcon(newIcon);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_NEW);
- fileMenu.add(menu);
-
- menu = new JMenuItem(LABEL_OPEN, KeyEvent.VK_O);
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,InputEvent.CTRL_MASK));
- menu.setIcon(openIcon);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_OPEN);
- fileMenu.add(menu);
-
- menu = new JMenuItem(LABEL_SAVE, KeyEvent.VK_S);
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK));
- menu.setIcon(saveIcon);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_SAVE);
- fileMenu.add(menu);
-
- menu = new JMenuItem(LABEL_SAVE_AS, KeyEvent.VK_A);
- menu.setIcon(saveAsIcon);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_SAVE_AS);
- fileMenu.add(menu);
-
- recentFilesMenu = new JMenu(LABEL_RECENT_FILES);
- recentFilesMenu.setIcon(emptyIcon);
- recentFilesMenu.setActionCommand(LABEL_RECENT_FILES);
- fileMenu.add(recentFilesMenu);
-
- fileMenu.addSeparator();
-
- JMenu importM = new JMenu(LABEL_IMPORT);
- importM.setIcon(importIcon);
- fileMenu.add(importM);
-
- menu = new JMenuItem(LABEL_IMPORT_TEX, KeyEvent.VK_X);
- menu.setIcon(insertPSTricksIcon);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_IMPORT_TEX);
- importM.add(menu);
-
- exportAsMenu = new JMenu(LABEL_EXPORT_AS);
- exportAsMenu.setIcon(exportIcon);
- fileMenu.add(exportAsMenu);
- exportAsMenu.setEnabled(false);
-
- menu = new JMenuItem(LABEL_EXPORT_TRICKS, KeyEvent.VK_T);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_EXPORT_TRICKS);
- exportAsMenu.add(menu);
-
- menu = new JMenuItem(LABEL_EXPORT_JPG, KeyEvent.VK_J);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_EXPORT_JPG);
- exportAsMenu.add(menu);
-
- menu = new JMenuItem(LABEL_EXPORT_PNG, KeyEvent.VK_P);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_EXPORT_PNG);
- exportAsMenu.add(menu);
-
- menu = new JMenuItem(LABEL_EXPORT_EPS, KeyEvent.VK_E);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_EXPORT_EPS);
- exportAsMenu.add(menu);
-
- menu = new JMenuItem(LABEL_EXPORT_BMP, KeyEvent.VK_B);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_EXPORT_BMP);
- exportAsMenu.add(menu);
-
- menu = new JMenuItem(LABEL_EXPORT_PPM, KeyEvent.VK_N);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_EXPORT_PPM);
- exportAsMenu.add(menu);
-
- exportTemplateMenu = new JMenuItem(LABEL_TEMPLATE_EXPORT);
- exportTemplateMenu.addActionListener(menusListener);
- exportTemplateMenu.setActionCommand(LABEL_TEMPLATE_EXPORT);
- exportAsMenu.add(exportTemplateMenu);
- exportTemplateMenu.setEnabled(false);
-
- fileMenu.addSeparator();
-
- menu = new JMenuItem(LABEL_BATCH_CONVERT, KeyEvent.VK_V);
- menu.addActionListener(menusListener);
- menu.setIcon(batchConvertIcon);
- menu.setActionCommand(LABEL_BATCH_CONVERT);
- fileMenu.add(menu);
-
- fileMenu.addSeparator();
-
- preferencesMenu = new JMenuItem(LABEL_PREFERENCES, KeyEvent.VK_P);
- preferencesMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,InputEvent.CTRL_MASK));
- preferencesMenu.setIcon(preferencesIcon);
- preferencesMenu.addActionListener(this);
- preferencesMenu.setActionCommand(LABEL_PREFERENCES);
- fileMenu.add(preferencesMenu);
-
- fileMenu.addSeparator();
-
- menu = new JMenuItem(LABEL_PRINT_CODE, KeyEvent.VK_E);
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,InputEvent.CTRL_MASK));
- menu.setIcon(printCodeIcon);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_PRINT_CODE);
- fileMenu.add(menu);
-
- menu = new JMenuItem(LABEL_PRINT_DRAW, KeyEvent.VK_D);
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D,InputEvent.CTRL_MASK));
- menu.setIcon(printDrawIcon);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_PRINT_DRAW);
- fileMenu.add(menu);
-
- fileMenu.addSeparator();
-
- menu = new JMenuItem(LABEL_QUIT, KeyEvent.VK_Q);
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W,InputEvent.CTRL_MASK));
- menu.setIcon(emptyIcon);
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_QUIT);
- fileMenu.add(menu);
-
- menu = new JMenuItem(LABEL_HELP, KeyEvent.VK_H);
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
- menu.setIcon(helpIcon);
- menu.addActionListener(this);
- menu.setActionCommand(LABEL_HELP);
- helpMenu.add(menu);
-
- menu = new JMenuItem(LaTeXDrawLang.getString1_9("LaTeXDrawFrame.3"), KeyEvent.VK_S); //$NON-NLS-1$
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
- menu.setIcon(helpIcon);
- menu.addActionListener(menusListener);
- menu.setActionCommand(MenusListener.ACTION_CMD_SHORTCUTS);
- helpMenu.add(menu);
-
- helpMenu.addSeparator();
-
- if(WITH_UPDATE)
- {
- menu = new JMenuItem(LaTeXDrawLang.getString1_9("LaTeXDrawFrame.4"), KeyEvent.VK_U); //$NON-NLS-1$
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));
- menu.setIcon(emptyIcon);
- menu.addActionListener(menusListener);
- menu.setActionCommand(MenusListener.LABEL_CHECK_UPDATE);
- helpMenu.add(menu);
-
- helpMenu.addSeparator();
- }
-
- menu = new JMenuItem(LABEL_ABOUT, KeyEvent.VK_A);
- menu.setIcon(aboutIcon);
- menu.addActionListener(this);
- menu.setActionCommand(LABEL_ABOUT);
- helpMenu.add(menu);
-
- drawMenu.add(createTemplateMenu());
- drawMenu.addSeparator();
-
- menu = new JMenu(LaTeXDrawLang.getString1_9("LaTeXDrawFrame.5")); //$NON-NLS-1$
- menu.setIcon(emptyIcon);
- drawMenu.add(menu);
-
- menuLine = new JRadioButtonMenuItem(LABEL_LINE, lineIcon);
- menuLine.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, 0));
- menuLine.setMnemonic(KeyEvent.VK_L);
- menuLine.addActionListener(menusListener);
- menuLine.setActionCommand(LABEL_LINE);
- menu.add(menuLine);
- drawMenuGroup.add(menuLine);
-
- menuJoinedLines = new JRadioButtonMenuItem(LABEL_JOINED_LINES, joinedLinesIcon);
- menuJoinedLines.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J,0));
- menuJoinedLines.setMnemonic(KeyEvent.VK_J);
- menuJoinedLines.addActionListener(menusListener);
- menuJoinedLines.setActionCommand(LABEL_JOINED_LINES);
- menu.add(menuJoinedLines);
- drawMenuGroup.add(menuJoinedLines);
-
- menuPoly = new JRadioButtonMenuItem(LABEL_POLY, polygonIcon);
- menuPoly.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,0));
- menuPoly.setMnemonic(KeyEvent.VK_P);
- menuPoly.addActionListener(menusListener);
- menuPoly.setActionCommand(LABEL_POLY);
- menu.add(menuPoly);
- drawMenuGroup.add(menuPoly);
- menuPoly.setSelected(false);
-
- menuDot = new JRadioButtonMenuItem(LABEL_DOT, dotIcon);
- menuDot.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D,0));
- menuDot.setMnemonic(KeyEvent.VK_D);
- menuDot.addActionListener(menusListener);
- menuDot.setActionCommand(LABEL_DOT);
- menu.add(menuDot);
- drawMenuGroup.add(menuDot);
- menuDot.setSelected(false);
-
- menuRect = new JRadioButtonMenuItem(LABEL_RECT, rectIcon);
- menuRect.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,0));
- menuRect.setMnemonic(KeyEvent.VK_R);
- menuRect.addActionListener(menusListener);
- menuRect.setActionCommand(LABEL_RECT);
- menu.add(menuRect);
- drawMenuGroup.add(menuRect);
- menuRect.setSelected(false);
-
- menuSquare = new JRadioButtonMenuItem(LABEL_SQUARE, squareIcon);
- menuSquare.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,0));
- menuSquare.setMnemonic(KeyEvent.VK_S);
- menuSquare.addActionListener(menusListener);
- menuSquare.setActionCommand(LABEL_SQUARE);
- menu.add(menuSquare);
- drawMenuGroup.add(menuSquare);
- menuSquare.setSelected(false);
-
- menuRhombus = new JRadioButtonMenuItem(LABEL_RHOMBUS, rhombusIcon);
- menuRhombus.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H,0));
- menuRhombus.setMnemonic(KeyEvent.VK_H);
- menuRhombus.addActionListener(menusListener);
- menuRhombus.setActionCommand(LABEL_RHOMBUS);
- menu.add(menuRhombus);
- drawMenuGroup.add(menuRhombus);
- menuRhombus.setSelected(false);
-
- menuTriangle = new JRadioButtonMenuItem(LABEL_TRIANGLE, triangleIcon);
- menuTriangle.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T,0));
- menuTriangle.setMnemonic(KeyEvent.VK_T);
- menuTriangle.addActionListener(menusListener);
- menuTriangle.setActionCommand(LABEL_TRIANGLE);
- menu.add(menuTriangle);
- drawMenuGroup.add(menuTriangle);
- menuTriangle.setSelected(false);
-
- menuEllipse = new JRadioButtonMenuItem(LABEL_ELLIPSE, ellipseIcon);
- menuEllipse.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,0));
- menuEllipse.setMnemonic(KeyEvent.VK_E);
- menuEllipse.addActionListener(menusListener);
- menuEllipse.setActionCommand(LABEL_ELLIPSE);
- menu.add(menuEllipse);
- drawMenuGroup.add(menuEllipse);
- menuEllipse.setSelected(false);
-
- menuCircle = new JRadioButtonMenuItem(LABEL_CIRCLE, circleIcon);
- menuCircle.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,0));
- menuCircle.setMnemonic(KeyEvent.VK_C);
- menuCircle.addActionListener(menusListener);
- menuCircle.setActionCommand(LABEL_CIRCLE);
- menu.add(menuCircle);
- drawMenuGroup.add(menuCircle);
- menuCircle.setSelected(false);
-
- menuArc = new JRadioButtonMenuItem(LABEL_ARC, arcIcon);
- menuArc.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,0));
- menuArc.setMnemonic(KeyEvent.VK_A);
- menuArc.addActionListener(menusListener);
- menuArc.setActionCommand(LABEL_ARC);
- menu.add(menuArc);
- drawMenuGroup.add(menuArc);
- menuArc.setSelected(false);
-
- menuWedge = new JRadioButtonMenuItem(LABEL_WEDGE, wedgeIcon);
- menuWedge.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W,0));
- menuWedge.setMnemonic(KeyEvent.VK_W);
- menuWedge.addActionListener(menusListener);
- menuWedge.setActionCommand(LABEL_WEDGE);
- menu.add(menuWedge);
- drawMenuGroup.add(menuWedge);
- menuWedge.setSelected(false);
-
- menuChord = new JRadioButtonMenuItem(LABEL_CHORD, chordIcon);
- menuChord.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,0));
- menuChord.setMnemonic(KeyEvent.VK_O);
- menuChord.addActionListener(menusListener);
- menuChord.setActionCommand(LABEL_CHORD);
- menu.add(menuChord);
- drawMenuGroup.add(menuChord);
- menuChord.setSelected(false);
-
- menuBezierCurve = new JRadioButtonMenuItem(LABEL_BEZIER_CURVE, bezierCurveIcon);
- menuBezierCurve.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B,0));
- menuBezierCurve.setMnemonic(KeyEvent.VK_B);
- menuBezierCurve.addActionListener(menusListener);
- menuBezierCurve.setActionCommand(LABEL_BEZIER_CURVE);
- menu.add(menuBezierCurve);
- drawMenuGroup.add(menuBezierCurve);
- menuBezierCurve.setSelected(false);
-
- menuClosedBezierCurve = new JRadioButtonMenuItem(LABEL_CLOSED_BEZIER_CURVE, closedBezierIcon);
- menuClosedBezierCurve.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,0));
- menuClosedBezierCurve.setMnemonic(KeyEvent.VK_B);
- menuClosedBezierCurve.addActionListener(menusListener);
- menuClosedBezierCurve.setActionCommand(LABEL_CLOSED_BEZIER_CURVE);
- menu.add(menuClosedBezierCurve);
- drawMenuGroup.add(menuClosedBezierCurve);
- menuClosedBezierCurve.setSelected(false);
-
- menuGrid = new JRadioButtonMenuItem(LABEL_GRID, gridIcon);
- menuGrid.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G,0));
- menuGrid.setMnemonic(KeyEvent.VK_G);
- menuGrid.addActionListener(menusListener);
- menuGrid.setActionCommand(LABEL_GRID);
- menu.add(menuGrid);
- drawMenuGroup.add(menuGrid);
- menuGrid.setSelected(false);
-
- menuAxes = new JRadioButtonMenuItem(LABEL_AXES, axesIcon);
- menuAxes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z,0));
- menuAxes.setMnemonic(KeyEvent.VK_Z);
- menuAxes.addActionListener(menusListener);
- menuAxes.setActionCommand(LABEL_AXES);
- menu.add(menuAxes);
- drawMenuGroup.add(menuAxes);
- menuAxes.setSelected(false);
-
- menuPointsAkin = new JRadioButtonMenuItem(LABEL_POINTS_AKIN, pointsAkinIcon);
- menuPointsAkin.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K,0));
- menuPointsAkin.setMnemonic(KeyEvent.VK_K);
- menuPointsAkin.addActionListener(menusListener);
- menuPointsAkin.setActionCommand(LABEL_POINTS_AKIN);
- menu.add(menuPointsAkin);
- drawMenuGroup.add(menuPointsAkin);
- menuPointsAkin.setSelected(false);
-
- menuText = new JRadioButtonMenuItem(LABEL_TEXT, textIcon);
- menuText.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,0));
- menuText.setMnemonic(KeyEvent.VK_X);
- menuText.addActionListener(menusListener);
- menuText.setActionCommand(LABEL_TEXT);
- menu.add(menuText);
- drawMenuGroup.add(menuText);
- menuText.setSelected(false);
-
- menuSelect = new JRadioButtonMenuItem(LABEL_SELECT_FIGURE, selectIcon);
- menuSelect.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,0));
- menuSelect.addActionListener(menusListener);
- menuSelect.setActionCommand(LABEL_SELECT_FIGURE);
- drawMenu.add(menuSelect);
- drawMenuGroup.add(menuSelect);
- menuSelect.setSelected(true);
-
- deleteFigure = new JMenuItem(LABEL_DELETE, delIcon);
- deleteFigure.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0));
- deleteFigure.addActionListener(menusListener);
- deleteFigure.setActionCommand(LABEL_DELETE);
- deleteFigure.setEnabled(false);
- drawMenu.add(deleteFigure);
-
- updateToGridMenu = new JMenuItem(DrawPanel.LABEL_UPDATE_TO_GRID, emptyIcon);
- updateToGridMenu.setActionCommand(DrawPanel.ACTION_CMD_UPDATETOGRID);
- updateToGridMenu.addActionListener(drawPanel);
- drawMenu.add(updateToGridMenu);
-
- menu = new JMenuItem(LaTeXDrawLang.getString1_9("LaTeXDrawFrame.6"), emptyIcon); //$NON-NLS-1$
- menu.setToolTipText(LaTeXDrawLang.getString1_9("LaTeXDrawFrame.7")); //$NON-NLS-1$
- menu.setActionCommand(MenusListener.ACTION_VISIBLE_ALL_FIGURES);
- menu.addActionListener(menusListener);
- drawMenu.add(menu);
- drawMenu.addSeparator();
-
- propertiesFigureMenu = new JMenuItem(LABEL_FIGURE_PROPERTIES, propertiesIcon);
- propertiesFigureMenu.addActionListener(menusListener);
- propertiesFigureMenu.setActionCommand(LABEL_FIGURE_PROPERTIES);
- propertiesFigureMenu.setEnabled(false);
- drawMenu.add(propertiesFigureMenu);
-
- menu = new JMenuItem(LABEL_DRAW_PROPERTIES, propertiesIcon);
- menu.addActionListener(this);
- menu.setActionCommand(LABEL_DRAW_PROPERTIES);
- drawMenu.add(menu);
-
- drawMenu.addSeparator();
-
- displayBorders = new JCheckBoxMenuItem(LABEL_DISPLAY_BORDERS, bordersIcon);
- displayBorders.addActionListener(menusListener);
- displayBorders.setActionCommand(LABEL_DISPLAY_BORDERS);
- displayBorders.setSelected(false);
- drawMenu.add(displayBorders);
-
- autoAdjustBorders = new JCheckBoxMenuItem(LABEL_AUTO_ADJUST_BORDERS, autoBordersIcon);
- autoAdjustBorders.addActionListener(menusListener);
- autoAdjustBorders.setActionCommand(LABEL_AUTO_ADJUST_BORDERS);
- autoAdjustBorders.setSelected(true);
- drawMenu.add(autoAdjustBorders);
-
-
- displayXScale = new JCheckBoxMenuItem(LABEL_DISPLAY_XSCALE, emptyIcon);
- displayXScale.addActionListener(menusListener);
- displayXScale.setActionCommand(LABEL_DISPLAY_XSCALE);
- displayXScale.setSelected(DEFAULT_DISPLAY_XSCALE);
- displayM.add(displayXScale);
-
- displayYScale = new JCheckBoxMenuItem(LABEL_DISPLAY_YSCALE, emptyIcon);
- displayYScale.addActionListener(menusListener);
- displayYScale.setActionCommand(LABEL_DISPLAY_YSCALE);
- displayYScale.setSelected(DEFAULT_DISPLAY_YSCALE);
- displayM.add(displayYScale);
-
- JMenu menuGrill = new JMenu(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.9")); //$NON-NLS-1$
- menuGrill.setIcon(displayGridIcon);
-
- displayGrid = new JCheckBoxMenuItem(LABEL_DISPLAY_GRID, emptyIcon);
- displayGrid.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.10")); //$NON-NLS-1$
- displayGrid.addActionListener(this);
- displayGrid.setActionCommand(LABEL_DISPLAY_GRID);
- displayGrid.setSelected(DEFAULT_DISPLAY_GRID && DrawContainer.DEFAULT_IS_CLASSIC_GRID_DRAWN);
- menuGrill.add(displayGrid);
- displayM.add(menuGrill);
-
- displayPersoGrid = new JCheckBoxMenuItem(LABEL_DISPLAY_PERSO_GRID, emptyIcon);
- displayPersoGrid.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.11")); //$NON-NLS-1$
- displayPersoGrid.addActionListener(this);
- displayPersoGrid.setActionCommand(LABEL_DISPLAY_PERSO_GRID);
- displayPersoGrid.setSelected(DEFAULT_DISPLAY_GRID && !DrawContainer.DEFAULT_IS_CLASSIC_GRID_DRAWN);
- menuGrill.add(displayPersoGrid);
-
- displayCodePanel = new JCheckBoxMenuItem(LABEL_DISPLAY_CODE_PANEL, emptyIcon);
- displayCodePanel.addActionListener(this);
- displayCodePanel.setActionCommand(LABEL_DISPLAY_CODE_PANEL);
- displayCodePanel.setSelected(DEFAULT_DISPLAY_CODEPANEL);
- displayM.add(displayCodePanel);
-
- displayM.addSeparator();
-
- menu = new JMenuItem(LABEL_ZOOM_IN, zoomInIcon);
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ADD,0));
- menu.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.94")); //$NON-NLS-1$
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_ZOOM_IN);
- displayM.add(menu);
-
- menu = new JMenuItem(LABEL_ZOOM_OUT, zoomOutIcon);
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT,0));
- menu.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.95")); //$NON-NLS-1$
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_ZOOM_OUT);
- displayM.add(menu);
-
- menu = new JMenuItem(LABEL_ZOOM_DEFAULT, zoomDefaultIcon);
- menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F9,0));
- menu.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.96")); //$NON-NLS-1$
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_ZOOM_DEFAULT);
- displayM.add(menu);
-
- menu = new JMenuItem(LABEL_INSERT_CODE, insertPSTricksIcon);
- menu.setToolTipText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.11")); //$NON-NLS-1$
- menu.addActionListener(this);
- menu.setActionCommand(LABEL_INSERT_CODE);
- insertMenu.add(menu);
-
- menu = new JMenuItem(LABEL_INSERT_PIX, insertPicIcon);
- menu.setToolTipText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.12")); //$NON-NLS-1$
- menu.addActionListener(menusListener);
- menu.setActionCommand(LABEL_INSERT_PIX);
- insertMenu.add(menu);
-
- menu = new JMenuItem(LABEL_COMMENTS, commentIcon);
- menu.addActionListener(this);
- menu.setActionCommand(LABEL_COMMENTS);
- codeMenu.add(menu);
-
- codeMenu.addSeparator();
-
- menu = new JMenuItem(CodePanel.LABEL_COPY_ALL, copyIcon);
- menu.addActionListener(codePanel);
- menu.setActionCommand(CodePanel.LABEL_COPY_ALL);
- codeMenu.add(menu);
-
- codeMenu.addSeparator();
-
- menuAutoUpdate = new JCheckBoxMenuItem(CodePanel.LABEL_AUTO_UPDATE, emptyIcon);
- menuAutoUpdate.addActionListener(codePanel);
- menuAutoUpdate.setToolTipText(LaTeXDrawLang.getOthersString("CodePanel.tip")); //$NON-NLS-1$
- menuAutoUpdate.setActionCommand(CodePanel.LABEL_AUTO_UPDATE);
- menuAutoUpdate.setSelected(CodePanel.DEFAULT_AUTO_UPDATE);
- codeMenu.add(menuAutoUpdate);
-
- menuReloadCode = new JMenuItem(CodePanel.LABEL_RELOAD, reloadIcon);
- menuReloadCode.addActionListener(codePanel);
- menuReloadCode.setToolTipText(LaTeXDrawLang.getOthersString("CodePanel.updateCode")); //$NON-NLS-1$
- menuReloadCode.setActionCommand(CodePanel.LABEL_RELOAD);
- menuReloadCode.setSelected(!CodePanel.DEFAULT_AUTO_UPDATE);
- codeMenu.add(menuReloadCode);
-
- menuBar.add(fileMenu);
- menuBar.add(editMenu);
- menuBar.add(displayM);
- menuBar.add(drawMenu);
- menuBar.add(insertMenu);
- menuBar.add(codeMenu);
- menuBar.add(helpMenu);
- }
-
-
-
-
-
- /**
- * Initialise the toolbar of the application
- */
- private void createToolbar()
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.106")); //$NON-NLS-1$
- toolbar = new JToolBar();
- toolbar.setName(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.107")); //$NON-NLS-1$
- ButtonGroup drawButtonGroup = new ButtonGroup();
- JButton button;
-
- button = new JButton(newIcon);
- button.addActionListener(menusListener);
- button.setMargin(INSET_BUTTON);
- button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.108")); //$NON-NLS-1$
- button.setActionCommand(LABEL_NEW);
- toolbar.add(button);
-
- button = new JButton(openIcon);
- button.addActionListener(menusListener);
- button.setMargin(INSET_BUTTON);
- button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.109")); //$NON-NLS-1$
- button.setActionCommand(LABEL_OPEN);
- toolbar.add(button);
-
- button = new JButton(saveIcon);
- button.addActionListener(menusListener);
- button.setMargin(INSET_BUTTON);
- button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.110")); //$NON-NLS-1$
- button.setActionCommand(LABEL_SAVE);
- toolbar.add(button);
-
- toolbar.addSeparator();
-
- button = new JButton(zoomInIcon);
- button.addActionListener(menusListener);
- button.setMargin(INSET_BUTTON);
- button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.111")); //$NON-NLS-1$
- button.setActionCommand(LABEL_ZOOM_IN);
- toolbar.add(button);
-
- button = new JButton(zoomOutIcon);
- button.addActionListener(menusListener);
- button.setMargin(INSET_BUTTON);
- button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.112")); //$NON-NLS-1$
- button.setActionCommand(LABEL_ZOOM_OUT);
- toolbar.add(button);
-
- button = new JButton(zoomDefaultIcon);
- button.addActionListener(menusListener);
- button.setMargin(INSET_BUTTON);
- button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.113")); //$NON-NLS-1$
- button.setActionCommand(LABEL_ZOOM_DEFAULT);
- toolbar.add(button);
-
- toolbar.addSeparator();
-
- ListJToggleButton listGrid = new ListJToggleButton(this, displayGridIcon, ListJToggleButton.LOCATION_SOUTH);
- listGrid.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.12")); //$NON-NLS-1$
-
- magneticCB = new JCheckBox(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.13")); //$NON-NLS-1$
- magneticCB.setMargin(INSET_BUTTON);
- magneticCB.setActionCommand(LABEL_MAGNETIC_CB);
- magneticCB.addActionListener(this);
- magneticCB.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.14")); //$NON-NLS-1$
- listGrid.addComponent(magneticCB);
- listGrid.addSeparator();
-
- JLabel label = new JLabel(loadImageIcon("/res/gridGap.png"));//$NON-NLS-1$
- listGrid.addComponent(label);
-
- SpinnerModel model = new SpinnerNumberModel(DrawContainer.DEFAULT_PERSONAL_GRID_GAP,2,100000,1);
- persoGridGapField = new JSpinner(model);
- persoGridGapField.setEditor(new JSpinner.NumberEditor(persoGridGapField, "0"));//$NON-NLS-1$
- persoGridGapField.addChangeListener(this);
- persoGridGapField.setName(LABEL_PERSO_GRID_GAP_FIELD);
- persoGridGapField.setPreferredSize(new Dimension(45,25));
- persoGridGapField.setMaximumSize(new Dimension(45,25));
- persoGridGapField.addChangeListener(this);
- persoGridGapField.setEnabled(false);
- persoGridGapField.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.15")); //$NON-NLS-1$
- listGrid.addComponent(persoGridGapField);
- listGrid.addSeparator();
-
- toolbar.add(listGrid);
-
- ListJToggleButton listDelimitor = new ListJToggleButton(this, delimitorIcon, ListJToggleButton.LOCATION_SOUTH);
- listDelimitor.setToolTipText(LaTeXDrawLang.getString1_9("LaTeXDrawFrame.8")); //$NON-NLS-1$
- JPanel panelSliderDel = new JPanel();
- JLabel sliderLabel = new JLabel(LaTeXDrawLang.getString1_9("LaTeXDrawFrame.9"), SwingConstants.CENTER); //$NON-NLS-1$
- panelSliderDel.setLayout(new BoxLayout(panelSliderDel, BoxLayout.PAGE_AXIS));
- panelSliderDel.add(sliderLabel);
- sliderLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
- sliderDelimitor = new JSlider(0, 255);
- sliderDelimitor.setToolTipText(LaTeXDrawLang.getString1_9("LaTeXDrawFrame.10")); //$NON-NLS-1$
- sliderDelimitor.setName(NAME_SLIDER_DELIMITOR);
- sliderDelimitor.setMajorTickSpacing(50);
- sliderDelimitor.setPaintTicks(true);
- sliderDelimitor.setPaintLabels(true);
- sliderDelimitor.addChangeListener(this);
- panelSliderDel.add(sliderDelimitor);
- listDelimitor.addComponent(panelSliderDel);
- listDelimitor.addSeparator();
-
- toolbar.add(listDelimitor);
- toolbar.addSeparator();
-
- buttonImageUndo = new JButton(undoIcon);
- buttonImageUndo.addActionListener(menusListener);
- buttonImageUndo.setMargin(INSET_BUTTON);
- buttonImageUndo.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.114")); //$NON-NLS-1$
- buttonImageUndo.setActionCommand(LABEL_UNDO);
- toolbar.add(buttonImageUndo);
-
- buttonImageRedo = new JButton(redoIcon);
- buttonImageRedo.addActionListener(menusListener);
- buttonImageRedo.setMargin(INSET_BUTTON);
- buttonImageRedo.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.115")); //$NON-NLS-1$
- buttonImageRedo.setActionCommand(LABEL_REDO);
- toolbar.add(buttonImageRedo);
-
- toolbar.addSeparator();
-
- ListJToggleButton ltb = new ListJToggleButton(this, lineIcon, ListJToggleButton.LOCATION_SOUTH);
- ltb.setToolTipText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.13")); //$NON-NLS-1$
- toolbar.add(ltb);
-
- buttonImageLine = new JToggleButton(lineIcon);
- buttonImageLine.addActionListener(menusListener);
- buttonImageLine.setMargin(INSET_BUTTON);
- buttonImageLine.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.116")); //$NON-NLS-1$
- buttonImageLine.setActionCommand(LABEL_LINE);
- drawButtonGroup.add(buttonImageLine);
- ltb.addComponent(buttonImageLine);
-
- buttonImageJoinedLines = new JToggleButton(joinedLinesIcon);
- buttonImageJoinedLines.addActionListener(menusListener);
- buttonImageJoinedLines.setMargin(INSET_BUTTON);
- buttonImageJoinedLines.setToolTipText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.14")); //$NON-NLS-1$
- buttonImageJoinedLines.setActionCommand(LABEL_JOINED_LINES);
- drawButtonGroup.add(buttonImageJoinedLines);
- ltb.addComponent(buttonImageJoinedLines);
- ltb.addSeparator();
-
- buttonImageDot = new JToggleButton(dotIcon);
- buttonImageDot.addActionListener(menusListener);
- buttonImageDot.setMargin(INSET_BUTTON);
- buttonImageDot.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.117")); //$NON-NLS-1$
- buttonImageDot.setActionCommand(LABEL_DOT);
- drawButtonGroup.add(buttonImageDot);
- toolbar.add(buttonImageDot);
-
- ltb = new ListJToggleButton(this, rectIcon, ListJToggleButton.LOCATION_SOUTH);
- ltb.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.118")); //$NON-NLS-1$
- toolbar.add(ltb);
-
- buttonImageRect = new JToggleButton(rectIcon);
- buttonImageRect.addActionListener(menusListener);
- buttonImageRect.setMargin(INSET_BUTTON);
- buttonImageRect.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.119")); //$NON-NLS-1$
- buttonImageRect.setActionCommand(LABEL_RECT);
- drawButtonGroup.add(buttonImageRect);
- ltb.addComponent(buttonImageRect);
-
- buttonImageSquare = new JToggleButton(squareIcon);
- buttonImageSquare.addActionListener(menusListener);
- buttonImageSquare.setMargin(INSET_BUTTON);
- buttonImageSquare.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.120")); //$NON-NLS-1$
- buttonImageSquare.setActionCommand(LABEL_SQUARE);
- drawButtonGroup.add(buttonImageSquare);
- ltb.addComponent(buttonImageSquare);
- ltb.addSeparator();
-
- ltb = new ListJToggleButton(this, polygonIcon, ListJToggleButton.LOCATION_SOUTH);
- ltb.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.121")); //$NON-NLS-1$
- toolbar.add(ltb);
-
- buttonImagePoly = new JToggleButton(polygonIcon);
- buttonImagePoly.addActionListener(menusListener);
- buttonImagePoly.setMargin(INSET_BUTTON);
- buttonImagePoly.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.122")); //$NON-NLS-1$
- buttonImagePoly.setActionCommand(LABEL_POLY);
- drawButtonGroup.add(buttonImagePoly);
- ltb.addComponent(buttonImagePoly);
-
- buttonImageRhombus = new JToggleButton(rhombusIcon);
- buttonImageRhombus.addActionListener(menusListener);
- buttonImageRhombus.setMargin(INSET_BUTTON);
- buttonImageRhombus.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.123")); //$NON-NLS-1$
- buttonImageRhombus.setActionCommand(LABEL_RHOMBUS);
- drawButtonGroup.add(buttonImageRhombus);
- ltb.addComponent(buttonImageRhombus);
-
- buttonImageTriangle = new JToggleButton(triangleIcon);
- buttonImageTriangle.addActionListener(menusListener);
- buttonImageTriangle.setMargin(INSET_BUTTON);
- buttonImageTriangle.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.124")); //$NON-NLS-1$
- buttonImageTriangle.setActionCommand(LABEL_TRIANGLE);
- drawButtonGroup.add(buttonImageTriangle);
- ltb.addComponent(buttonImageTriangle);
- ltb.addSeparator();
-
- ltb = new ListJToggleButton(this, ellipseIcon, ListJToggleButton.LOCATION_SOUTH);
- ltb.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.125")); //$NON-NLS-1$
- toolbar.add(ltb);
-
- buttonImageEllipse = new JToggleButton(ellipseIcon);
- buttonImageEllipse.addActionListener(menusListener);
- buttonImageEllipse.setMargin(INSET_BUTTON);
- buttonImageEllipse.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.126")); //$NON-NLS-1$
- buttonImageEllipse.setActionCommand(LABEL_ELLIPSE);
- drawButtonGroup.add(buttonImageEllipse);
- ltb.addComponent(buttonImageEllipse);
-
- buttonImageCircle = new JToggleButton(circleIcon);
- buttonImageCircle.addActionListener(menusListener);
- buttonImageCircle.setMargin(INSET_BUTTON);
- buttonImageCircle.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.127")); //$NON-NLS-1$
- buttonImageCircle.setActionCommand(LABEL_CIRCLE);
- drawButtonGroup.add(buttonImageCircle);
- ltb.addComponent(buttonImageCircle);
- ltb.addSeparator();
-
- ltb = new ListJToggleButton(this, arcIcon, ListJToggleButton.LOCATION_SOUTH);
- ltb.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.128")); //$NON-NLS-1$
- toolbar.add(ltb);
-
- buttonImageArc = new JToggleButton(arcIcon);
- buttonImageArc.addActionListener(menusListener);
- buttonImageArc.setMargin(INSET_BUTTON);
- buttonImageArc.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.129")); //$NON-NLS-1$
- buttonImageArc.setActionCommand(LABEL_ARC);
- drawButtonGroup.add(buttonImageArc);
- ltb.addComponent(buttonImageArc);
-
- buttonImageWedge = new JToggleButton(wedgeIcon);
- buttonImageWedge.addActionListener(menusListener);
- buttonImageWedge.setMargin(INSET_BUTTON);
- buttonImageWedge.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.130")); //$NON-NLS-1$
- buttonImageWedge.setActionCommand(LABEL_WEDGE);
- drawButtonGroup.add(buttonImageWedge);
- ltb.addComponent(buttonImageWedge);
-
- buttonImageChord = new JToggleButton(chordIcon);
- buttonImageChord.addActionListener(menusListener);
- buttonImageChord.setMargin(INSET_BUTTON);
- buttonImageChord.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.131")); //$NON-NLS-1$
- buttonImageChord.setActionCommand(LABEL_CHORD);
- drawButtonGroup.add(buttonImageChord);
- ltb.addComponent(buttonImageChord);
- ltb.addSeparator();
-
- ltb = new ListJToggleButton(this, closedBezierIcon, ListJToggleButton.LOCATION_SOUTH);
- ltb.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.132")); //$NON-NLS-1$
- toolbar.add(ltb);
-
- buttonImageClosedBezierCurve = new JToggleButton(closedBezierIcon);
- buttonImageClosedBezierCurve.addActionListener(menusListener);
- buttonImageClosedBezierCurve.setMargin(INSET_BUTTON);
- buttonImageClosedBezierCurve.setToolTipText(LaTeXDrawLang.getString1_9("LaTeXDrawFrame.11")); //$NON-NLS-1$
- buttonImageClosedBezierCurve.setActionCommand(LABEL_CLOSED_BEZIER_CURVE);
- drawButtonGroup.add(buttonImageClosedBezierCurve);
- ltb.addComponent(buttonImageClosedBezierCurve);
-
- buttonImageBezierCurve = new JToggleButton(bezierCurveIcon);
- buttonImageBezierCurve.addActionListener(menusListener);
- buttonImageBezierCurve.setMargin(INSET_BUTTON);
- buttonImageBezierCurve.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.132")); //$NON-NLS-1$
- buttonImageBezierCurve.setActionCommand(LABEL_BEZIER_CURVE);
- drawButtonGroup.add(buttonImageBezierCurve);
- ltb.addComponent(buttonImageBezierCurve);
- ltb.addSeparator();
-
- ltb = new ListJToggleButton(this, gridIcon, ListJToggleButton.LOCATION_SOUTH);
- ltb.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.16")); //$NON-NLS-1$
-
- buttonImageGrid = new JToggleButton(gridIcon);
- buttonImageGrid.addActionListener(menusListener);
- buttonImageGrid.setMargin(INSET_BUTTON);
- buttonImageGrid.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.133")); //$NON-NLS-1$
- buttonImageGrid.setActionCommand(LABEL_GRID);
- drawButtonGroup.add(buttonImageGrid);
- ltb.addComponent(buttonImageGrid);
-
- buttonImageAxes = new JToggleButton(axesIcon);
- buttonImageAxes.addActionListener(menusListener);
- buttonImageAxes.setMargin(INSET_BUTTON);
- buttonImageAxes.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.17")); //$NON-NLS-1$
- buttonImageAxes.setActionCommand(LABEL_AXES);
- drawButtonGroup.add(buttonImageAxes);
- ltb.addComponent(buttonImageAxes);
- ltb.addSeparator();
- toolbar.add(ltb);
-
- buttonImagePointsAkin = new JToggleButton(pointsAkinIcon);
- buttonImagePointsAkin.addActionListener(menusListener);
- buttonImagePointsAkin.setMargin(INSET_BUTTON);
- buttonImagePointsAkin.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.134")); //$NON-NLS-1$
- buttonImagePointsAkin.setActionCommand(LABEL_POINTS_AKIN);
- drawButtonGroup.add(buttonImagePointsAkin);
- toolbar.add(buttonImagePointsAkin);
-
- buttonImageText = new JToggleButton(textIcon);
- buttonImageText.addActionListener(menusListener);
- buttonImageText.setMargin(INSET_BUTTON);
- buttonImageText.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.135")); //$NON-NLS-1$
- buttonImageText.setActionCommand(LABEL_TEXT);
- drawButtonGroup.add(buttonImageText);
- toolbar.add(buttonImageText);
-
- toolbar.addSeparator();
-
- buttonImageSelect = new JToggleButton(selectIcon);
- buttonImageSelect.addActionListener(menusListener);
- buttonImageSelect.setMargin(INSET_BUTTON);
- buttonImageSelect.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.136") + //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.137") + //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.138")); //$NON-NLS-1$
- buttonImageSelect.setActionCommand(LABEL_SELECT_FIGURE);
- drawButtonGroup.add(buttonImageSelect);
- drawButtonGroup.setSelected(buttonImageSelect.getModel(), true);
- toolbar.add(buttonImageSelect);
-
- buttonImageDel = new JButton(delIcon);
- buttonImageDel.addActionListener(menusListener);
- buttonImageDel.setMargin(INSET_BUTTON);
- buttonImageDel.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.139")); //$NON-NLS-1$
- buttonImageDel.setActionCommand(LABEL_DELETE);
- buttonImageDel.setEnabled(false);
- toolbar.add(buttonImageDel);
-
- toolbar.addSeparator();
-
- buttonImageProperties = new JButton(propertiesIcon);
- buttonImageProperties.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.140")); //$NON-NLS-1$
- buttonImageProperties.addActionListener(menusListener);
- buttonImageProperties.setMargin(INSET_BUTTON);
- buttonImageProperties.setActionCommand(LABEL_FIGURE_PROPERTIES);
- buttonImageProperties.setEnabled(false);
- toolbar.add(buttonImageProperties);
-
- toolbar.addSeparator();
-
- buttonImageBorders = new JToggleButton(bordersIcon);
- buttonImageBorders.addActionListener(menusListener);
- buttonImageBorders.setMargin(INSET_BUTTON);
- buttonImageBorders.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.141") + //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.142") + //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.143") + //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.144")); //$NON-NLS-1$
- buttonImageBorders.setActionCommand(LABEL_DISPLAY_BORDERS);
- toolbar.add(buttonImageBorders);
-
- button = new JButton(texEditorIcon);
- button.addActionListener(this);
- button.setMargin(INSET_BUTTON);
- button.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.18")); //$NON-NLS-1$
- button.setActionCommand(LABEL_TEX_EDITOR);
- toolbar.add(button);
-
- copyCodeButton = new JButton(copyIcon);
- copyCodeButton.addActionListener(codePanel);
- copyCodeButton.setMargin(INSET_BUTTON);
- copyCodeButton.setToolTipText(CodePanel.LABEL_COPY_ALL);
- copyCodeButton.setActionCommand(CodePanel.LABEL_COPY_ALL);
- copyCodeButton.setVisible(!DEFAULT_DISPLAY_CODEPANEL);
- toolbar.add(copyCodeButton);
-
- requestFocus();
- }
-
-
-
- /**
- * Allows to create the menu "template".<br>
- * 09/07/06: fix #1553683
- * @return The menu template
- */
- private JMenu createTemplateMenu()
- {
- try
- {
- menuTemplate = new MenuTemplate(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.103"), this); //$NON-NLS-1$
- menuTemplate.setIcon(emptyIcon);
-
- }catch(Exception e)
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.105")); //$NON-NLS-1$
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- return menuTemplate;
- }
-
-
-
- /**
- * Allows to get the path for open/save actions
- * @return The path for open/save actions
- */
- public static String getPathExport()
- {
- return pathExport;
- }
-
-
-
-
- /**
- * Allows to get the path for exportations actions
- * @return The path for exportations actions
- */
- public static String getPathOpen()
- {
- return pathOpen;
- }
-
-
-
-
- /**
- * Allows to get the current choice of the user
- * @return The current choice of the user
- */
- public String getCurrentChoice()
- {
- return currentChoice;
- }
-
-
-
- /**
- * Allows to get the codePanel
- * @return The codePanel
- */
- public CodePanel getCodePanel()
- {
- return codePanel;
- }
-
-
-
- /**
- * Allows to get the drawPanel
- * @return The drawPanel
- */
- public DrawPanel getDrawPanel()
- {
- return drawPanel;
- }
-
-
-
- /**
- * Allows to set if the grid must be displayed.
- * @param display True : the grid must be displayed.
- * @param classicGrid Define if it is the classic grid which must be drawn (only if display=true).
- */
- public void displayGrid(boolean display, boolean classicGrid)
- {
- if(display)
- {
- displayGrid.setSelected(classicGrid);
- persoGridGapField.setEnabled(!classicGrid);
- displayPersoGrid.setSelected(!classicGrid);
- drawPanel.draw.setClassicGridDrawn(classicGrid);
- }
- else
- {
- displayGrid.setSelected(false);
- persoGridGapField.setEnabled(false);
- displayPersoGrid.setSelected(false);
- }
-
- drawPanel.setIsGridDisplay(display);
- drawPanel.setIsModified(true);
- }
-
-
-
- /**
- * Allows to set if the XScale must be displayed
- * @param display True : the XScale must be displayed
- */
- public void displayXScale(boolean display)
- {
- displayXScale.setSelected(display);
- xScale.setVisible(display);
- try {drawPanel.setIsModified(true);}
- catch (Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- displayXScale.setSelected(display);
- }
-
-
-
- /**
- * Allows to set if the YScale must be displayed
- * @param display True : the YScale must be displayed
- */
- public void displayYScale(boolean display)
- {
- yScale.setVisible(display);
- try {drawPanel.setIsModified(true);}
- catch (Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- displayYScale.setSelected(display);
- }
-
-
-
-
- /**
- * Allows to set if the borders of the drawing must be displayed
- * @param display True : the borders of the drawing must be displayed
- */
- public void displayBorders(boolean display)
- {
- try
- {
- drawPanel.displayBorders(display);
- displayBorders.setSelected(display);
- buttonImageBorders.setSelected(display);
- drawPanel.setIsModified(true);
- } catch (Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- }
-
-
-
-
-
- /**
- * Allows to set if the code panel must be displayed
- * @param display True: the code panel must be displayed
- */
- public void displayCodePanel(boolean display)
- {
- displayCodePanel.setSelected(display);
- copyCodeButton.setVisible(!display);
-
- if(display)
- {
- codePanel.setVisible(true);
- codePanel.setIsInAutoUpdate(formerIsInAutoUpdate);
- splitPane.setDividerLocation(formerDividerLocation);
- }
- else
- {
- formerIsInAutoUpdate = codePanel.isInAutoUpdate();
- codePanel.setIsInAutoUpdate(false);
- formerDividerLocation = splitPane.getDividerLocation();
- codePanel.setVisible(false);
- }
- splitPane.revalidate();
- }
-
-
-
- /**
- * Allows to set the path for open/save actions
- * @param path The new path
- */
- public void setPathOpen(String path)
- {
- pathOpen = path;
- if(fileChooserSave!=null)
- fileChooserSave.setCurrentDirectory(new File(path));
- }
-
-
-
-
- /**
- * Allows to set the path for exportations actions
- * @param path The new path
- */
- public void setPathExport(String path)
- {
- pathExport = path;
- if(fileChooserExport!=null)
- fileChooserExport.setCurrentDirectory(new File(path));
- }
-
-
-
-
- /**
- * Allows to set if the menu "paste" must be enable or not
- * @param mustBeEnable True : the menu "paste" must be activated
- */
- public void setMenuPaste(boolean mustBeEnable)
- {
- pasteMenu.setEnabled(mustBeEnable);
- }
-
-
-
-
- /**
- * Allows to set if the menu "copy" must be enable or not
- * @param mustBeEnable True : the menu "copy" must be activated
- */
- public void setMenuCopy(boolean mustBeEnable)
- {
- copyMenu.setEnabled(mustBeEnable);
- }
-
-
-
-
- /**
- * Allows to set the selected field of the choice lineChoice
- * @param choice The new selected choice
- */
- public void setLineChoice(String choice)
- {
- if(!Figure.isValidStyle(choice))
- throw new IllegalArgumentException();
-
- lineChoice.removeItemListener(this);
- lineChoice.setSelectedItem(choice);
- lineChoice.addItemListener(this);
- }
-
-
-
- /**
- * Allows to set the selected field of the choice <code>bordersPositionChoice</code>.
- * @param choice The new choice.
- * @since 1.9.1
- */
- public void setBorderChoice(String choice)
- {
- bordersPositionChoice.removeItemListener(this);
- bordersPositionChoice.setSelectedItem(choice);
- bordersPositionChoice.addItemListener(this);
- }
-
-
-
- /**
- * Allows to set the selected field of the choice <code>hatchChoice</code>.
- * @param choice The new choice.
- * @since 1.9.1
- */
- public void setHatchChoice(String choice)
- {
- hatchChoice.removeItemListener(this);
- hatchChoice.setSelectedItem(choice);
- hatchChoice.addItemListener(this);
- }
-
-
-
- /**
- * Allows to set the selected field of the choice lineArrowRChoice
- * @param choice The new selected choice
- */
- public void setLineArrowRChoice(String choice)
- {
- if(!PSTricksConstants.isValidArrowStyle(choice))
- throw new IllegalArgumentException();
-
- lineArrowRChoice.removeItemListener(this);
- lineArrowRChoice.setSelectedItem(choice);
- lineArrowRChoice.addItemListener(this);
- }
-
-
-
-
- /**
- * Allows to set the selected field of the choice lineArrowLChoice
- * @param choice The new selected choice
- */
- public void setLineArrowLChoice(String choice)
- {
- if(!PSTricksConstants.isValidArrowStyle(choice))
- throw new IllegalArgumentException();
-
- lineArrowLChoice.removeItemListener(this);
- lineArrowLChoice.setSelectedItem(choice);
- lineArrowLChoice.addItemListener(this);
- }
-
-
-
-
- /**
- * Allows to update the selected field in the Choice component
- * dotChoice
- * @param newChoice The choice which must be selected
- */
- public void setDotChoice(String newChoice)
- {
- if(!PSTricksConstants.isValidDotStyle(newChoice))
- throw new IllegalArgumentException();
-
- dotChoice.removeItemListener(this);
- dotChoice.setSelectedItem(newChoice);
- dotChoice.addItemListener(this);
- }
-
-
-
-
- /**
- * Allows to set the menu exportAs able or not
- * @param state It's new state
- */
- public void setExportAsMenu(boolean state)
- {
- exportAsMenu.setEnabled(state);
- }
-
-
-
- /**
- * Allows to set the value of the field thickness
- * @param thickness The new value of the field thickness
- */
- public void setThicknessFieldValue(float thickness)
- {
- thicknessField.removeChangeListener(this);
- thicknessField.setValue(Float.valueOf(thickness).doubleValue());
- thicknessField.addChangeListener(this);
- }
-
-
-
- public void setDotFieldValue(float width)
- {
- dotSizeField.removeChangeListener(this);
- dotSizeField.setValue(Float.valueOf(width).doubleValue());
- dotSizeField.addChangeListener(this);
- }
-
-
- /**
- * Allows to set the attribute "isModified" in the drawPanel
- * @param modified The new value of the attribute "isModified"
- */
- public void setIsModified(boolean modified)
- {
- drawPanel.setIsModified(modified);
- }
-
-
-
-
- /**
- * Allows to reinitialise some buttons
- */
- public void reinitializeButtons()
- {
- updateUndoRedo();
- codePanel.newProject();
- Delimitor.setOpacity(Delimitor.DEFAULT_OPACITY);
- sliderDelimitor.setValue(Delimitor.DEFAULT_OPACITY);
- persoGridGapField.setValue(DrawContainer.DEFAULT_PERSONAL_GRID_GAP);
- displayGrid.setSelected(false);
- displayPersoGrid.setSelected(false);
- persoGridGapField.setEnabled(false);
- magneticCB.setSelected(false);
- rotationButtons.setSelected(false);
- mirrorButtons.setSelected(false);
- drawPanel.setOnRotation(false);
- preferencesFrame.readPreferences();
- preferencesFrame.updateDrawPreferences();
- if(drawPropertiesFrame!=null)
- drawPropertiesFrame.setProperties();
- buttonImageSelect.setSelected(true);
- menuSelect.setSelected(true);
- autoAdjustBorders.setSelected(true);
- drawPanel.setMenuSelectedPopupGeneral(menuSelect.getActionCommand(),true);
- rotateButton.setSelected(false);
- drawPanel.setOnRotation(false);
- setCurrentChoice(LABEL_SELECT_FIGURE);
- }
-
-
-
-
- /**
- * Allows to update buttons undo/redo
- * (change their titles, ...)
- */
- public void updateUndoRedo()
- {
- if(undoManager.isEmptyRedo())
- {
- buttonImageRedo.setToolTipText(UndoRedoManager.EMPTY_REDO);
- redoMenu.setText(UndoRedoManager.EMPTY_REDO);
- }
- else
- {
- buttonImageRedo.setToolTipText(LABEL_REDO +" " +undoManager.getTextNextRedo());//$NON-NLS-1$
- redoMenu.setText(LABEL_REDO +" " +undoManager.getTextNextRedo());//$NON-NLS-1$
- }
-
- if(undoManager.isEmptyUndo())
- {
- undoMenu.setText(UndoRedoManager.EMPTY_UNDO);
- buttonImageUndo.setToolTipText(UndoRedoManager.EMPTY_UNDO);
- }
- else
- {
- undoMenu.setText(LABEL_UNDO +" " +undoManager.getTextNextUndo());//$NON-NLS-1$
- buttonImageUndo.setToolTipText(LABEL_UNDO +" " +undoManager.getTextNextUndo());//$NON-NLS-1$
- }
-
- undoMenu.setEnabled(!undoManager.isEmptyUndo());
- redoMenu.setEnabled(!undoManager.isEmptyRedo());
- buttonImageRedo.setEnabled(!undoManager.isEmptyRedo());
- buttonImageUndo.setEnabled(!undoManager.isEmptyUndo());
- }
-
-
-
-
- /**
- * Allows to update fields of the frame : if a figure is selected, its parameters are updated, else general parameters are used
- * to set the fields.
- */
- public void updateFrameFields()
- {
- try
- {
- Draw listSelected = drawPanel.getDraw().getSelected();
-
- if(listSelected!=null && listSelected.getNbFigures()==1)
- {
- Figure f = listSelected.getFigureAt(0);
-
- if(f!=null)
- {
- if(f instanceof Dot)
- {
- setDotFieldValue(((Dot)f).getWidth());
- setDotChoice(((Dot)f).getCurrentStyle());
- buttonInteriorColor.setVisible(f.canBeFilled());
- }
- else
- {
- if(f.canHaveArrow())
- {
- setLineArrowLChoice(((Arrowable)f).getArrow1Style());
- setLineArrowRChoice(((Arrowable)f).hasTwoLeftArrows() ?
- ArrowHead.invertArrowStyle(((Arrowable)f).getArrow2Style()) : ((Arrowable)f).getArrow2Style());
- }
-
- setThicknessFieldValue(f.getThickness());
- setLineChoice(f.getLineStyle());
- filledCheckBox.setSelected(f.canBeFilled() && f.isFilled());
- }
-
- buttonBordersColor.setColor(f.getLinesColor());
- setHatchChoice(f.getHatchingStyle());
- dbleBoundCheckBox.setSelected(f.isDoubleBoundaryable() && f.hasDoubleBoundary());
- shadowCheckBox.setSelected(f.hasShadow());
- updateFillCB();
-
- if(f.canHaveShadow())
- buttonShadowColor.setColor(f.getShadowColor());
-
- if(f.canBeFilled())
- {
- buttonBordersColor.setColor(f.getLinesColor());
- buttonInteriorColor.setColor(f.getInteriorColor());
- buttonGradientEndC.setColor(f.getGradientEndColor());
- buttonGradientStartC.setColor(f.getGradientStartColor());
- }
-
- if(f.canBeHatched())
- buttonHatchColor.setColor(f.getHatchingColor());
-
- if(f.isDoubleBoundaryable())
- buttonDbleBoundColor.setColor(f.getDoubleColor());
-
- if(f.isBordersMovable())
- setBorderChoice(f.getBordersPosition());
- }//if
- }
- else
- if(listSelected!=null && listSelected.getNbFigures()>1)
- {// We try to identify the figures' attributes that are equals.
- boolean ok;
- int i, size = listSelected.getNbFigures();
- Color linesC = listSelected.getFigureAt(0).getLinesColor();
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).isDoubleBoundaryable())
- ok = false;
-
- if(!ok)
- {
- boolean hasDbleBound = listSelected.getFigureAt(i-1).hasDoubleBoundary();
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).isDoubleBoundaryable() &&
- listSelected.getFigureAt(i).hasDoubleBoundary()!=hasDbleBound)
- ok = false;
-
- dbleBoundCheckBox.setSelected(ok ? hasDbleBound : genHasDbleBord);
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).hasDoubleBoundary())
- ok = false;
-
- if(!ok)
- {
- Color dbleC = listSelected.getFigureAt(i-1).getDoubleColor();
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).hasDoubleBoundary() &&
- !listSelected.getFigureAt(i).getDoubleColor().equals(dbleC))
- ok = false;
-
- genDbleBordCB.setColor(ok ? dbleC : genDbleC);
- }
- else
- genDbleBordCB.setColor(genDbleC);
- }
- else
- dbleBoundCheckBox.setSelected(genHasDbleBord);
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i) instanceof Arrowable)
- ok = false;
-
- if(!ok)
- {
- Arrowable arr = ((Arrowable)listSelected.getFigureAt(i-1));
- String arrow1S = arr.getArrow1Style();
- String arrow2S = arr.hasTwoLeftArrows() ? ArrowHead.invertArrowStyle(arr.getArrow2Style()) : arr.getArrow2Style();
- boolean ok2 = true;
- String str;
-
- for(i=0, ok=true; i<size; i++)
- if(listSelected.getFigureAt(i) instanceof Arrowable)
- {
- Arrowable a = (Arrowable)listSelected.getFigureAt(i);
- str = a.getArrow2Style();
-
- if(a.hasTwoLeftArrows())
- str = ArrowHead.invertArrowStyle(str);
-
- if(a.getArrow1Style().compareTo(arrow1S)!=0)
- ok = false;
-
- if(str.compareTo(arrow2S)!=0)
- ok2 = false;
- }
-
- setLineArrowLChoice(ok ? arrow1S : genLeftArrS);
- setLineArrowRChoice(ok2 ? arrow2S : genRightArrS);
- }
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i) instanceof Dot)
- ok = false;
-
- if(!ok)
- {
- String dotStyle = ((Dot)listSelected.getFigureAt(i-1)).getCurrentStyle();
- float width = ((Dot)listSelected.getFigureAt(i-1)).getWidth();
- boolean ok2 = true;
-
- for(i=0, ok=true; i<size; i++)
- if(listSelected.getFigureAt(i) instanceof Dot)
- {
- Dot d = (Dot)listSelected.getFigureAt(i);
-
- if(d.getCurrentStyle().compareTo(dotStyle)!=0)
- ok = false;
-
- if(d.getWidth()!=width)
- ok2 = false;
- }
-
- setDotChoice(ok ? dotStyle : genDotS);
- setDotFieldValue(ok2 ? width : genDotSize);
- }
- else setLineChoice(genLineStyleS);
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).isDashableOrDotable())
- ok = false;
-
- if(!ok)
- {
- String lineStyle = listSelected.getFigureAt(i-1).getLineStyle();
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).isDashableOrDotable() &&
- listSelected.getFigureAt(i).getLineStyle().compareTo(lineStyle)!=0)
- ok = false;
-
- setLineChoice(ok ? lineStyle : genLineStyleS);
- }
- else setLineChoice(genLineStyleS);
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).isBordersMovable())
- ok = false;
-
- if(!ok)
- {
- String bordPos = listSelected.getFigureAt(i-1).getBordersPosition();
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).isBordersMovable() &&
- listSelected.getFigureAt(i).getBordersPosition().compareTo(bordPos)!=0)
- ok = false;
-
- setBorderChoice(ok ? bordPos : genBordPosS);
- }
- else setBorderChoice(genBordPosS);
-
- for(i=1; i<size && ok; i++)
- if(!listSelected.getFigureAt(i).getLinesColor().equals(linesC))
- ok = false;
-
- genLineCB.setColor(ok ? linesC : genLineC);
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).isThicknessable())
- ok = false;
-
- if(!ok)
- {
- Float thickness = listSelected.getFigureAt(i-1).getThickness();
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).isThicknessable() && listSelected.getFigureAt(i).getThickness()!=thickness)
- ok = false;
-
- setThicknessFieldValue(ok ? thickness : genThickness);
- }
- else setThicknessFieldValue(genThickness);
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).canHaveShadow())
- ok = false;
-
- if(!ok)
- {
- boolean hasShadow = listSelected.getFigureAt(i-1).hasShadow();
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).canHaveShadow() && listSelected.getFigureAt(i).hasShadow()!=hasShadow)
- ok = false;
-
- shadowCheckBox.setSelected(ok ? hasShadow : genHasShadow);
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).hasShadow())
- ok = false;
-
- if(!ok)
- {
- Color shadC = listSelected.getFigureAt(i-1).getShadowColor();
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).hasShadow() && !listSelected.getFigureAt(i).getShadowColor().equals(shadC))
- ok = false;
-
- genShadowCB.setColor(ok ? shadC : genShadowC);
- }
- else
- genShadowCB.setColor(genShadowC);
- }
- else
- shadowCheckBox.setSelected(genHasShadow);
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).canBeFilled())
- ok = false;
-
- if(!ok)
- {
- int j = i-1;
- boolean isFilled = listSelected.getFigureAt(j).isFilled();
- String hatchS = listSelected.getFigureAt(j).getHatchingStyle();
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).canBeFilled() && listSelected.getFigureAt(i).isFilled()!=isFilled)
- ok = false;
-
- filledCheckBox.setSelected(ok ? isFilled : genIsFilled);
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).canBeFilled() &&
- (listSelected.getFigureAt(i).hasGradient() || listSelected.getFigureAt(i).isHatched()) &&
- listSelected.getFigureAt(i).getHatchingStyle().compareTo(hatchS)!=0)
- ok = false;
-
- setHatchChoice(ok ? hatchS : genHatchS);
-
- if(ok)
- if(listSelected.getFigureAt(j).hasGradient())
- {
- Color gradEndC = listSelected.getFigureAt(j).getGradientEndColor();
- Color gradStartC = listSelected.getFigureAt(j).getGradientStartColor();
- boolean okEnd = true;
-
- for(i=0, ok=true; i<size; i++)
- if(listSelected.getFigureAt(i).canBeHatched())
- {
- if(!listSelected.getFigureAt(i).getGradientEndColor().equals(gradEndC))
- okEnd = false;
- if(!listSelected.getFigureAt(i).getGradientStartColor().equals(gradStartC))
- ok = false;
- }
-
- genGradientStartCB.setColor(ok ? gradStartC : genGradientStartC);
- genGradientEndCB.setColor(okEnd ? gradEndC : genGradientEndC);
- genHatchCB.setColor(genHatchC);
- }
- else
- {
- Color hatchC = listSelected.getFigureAt(j).getHatchingColor();
-
- for(i=0, ok=true; i<size; i++)
- if(listSelected.getFigureAt(i).canBeHatched() &&
- !listSelected.getFigureAt(i).getHatchingColor().equals(hatchC))
- ok = false;
-
- genGradientStartCB.setColor(genGradientStartC);
- genGradientEndCB.setColor(genGradientEndC);
- genHatchCB.setColor(ok ? hatchC : genHatchC);
- }
- else
- {
- genGradientStartCB.setColor(genGradientStartC);
- genGradientEndCB.setColor(genGradientEndC);
- genHatchCB.setColor(genHatchC);
- }
-
- for(i=0, ok=true; i<size && ok; i++)
- if(listSelected.getFigureAt(i).isFilled())
- ok = false;
-
- if(!ok)
- {
- Color fillC = listSelected.getFigureAt(i-1).getInteriorColor();
-
- for(ok=true, i=0; i<size && ok; i++)
- if(listSelected.getFigureAt(i).isFilled() && !listSelected.getFigureAt(i).getInteriorColor().equals(fillC) &&
- !listSelected.getFigureAt(i).hasGradient())
- ok = false;
-
- genInteriorCB.setColor(ok ? fillC : genInteriorC);
- }
- else genInteriorCB.setColor(genInteriorC);
- }
- else
- {
- genInteriorCB.setColor(genInteriorC);
- setHatchChoice(genHatchS);
- filledCheckBox.setSelected(genIsFilled);
- buttonGradientStartC.setColor(genGradientStartC);
- buttonGradientEndC.setColor(genGradientEndC);
- buttonHatchColor.setColor(genHatchC);
- }
- }
- else// In this case, the general values are used.
- {
- setBorderChoice(genBordPosS);
- setLineChoice(genLineStyleS);
- setDotChoice(genDotS);
- dbleBoundCheckBox.setSelected(genHasDbleBord);
- shadowCheckBox.setSelected(genHasShadow);
- setHatchChoice(genHatchS);
- filledCheckBox.setSelected(genIsFilled);
- setLineArrowLChoice(genLeftArrS);
- setLineArrowRChoice(genRightArrS);
- setThicknessFieldValue(genThickness);
- genDbleBordCB.setColor(genDbleC);
- genGradientEndCB.setColor(genGradientEndC);
- genGradientStartCB.setColor(genGradientStartC);
- genInteriorCB.setColor(genInteriorC);
- genLineCB.setColor(genLineC);
- genHatchCB.setColor(genHatchC);
- genShadowCB.setColor(genShadowC);
- }
- }catch(Exception ex)
- {
- ex.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ex);
- }
- }
-
-
-
-
-
- /**
- * Allows to know if the user wants to auto adjust the
- * borders of the drawing.
- * @return True if the user wants it
- */
- public boolean isAutoAdjustBorders()
- {
- if(autoAdjustBorders==null)
- return false;
- return autoAdjustBorders.isSelected();
- }
-
-
-
-
- /**
- * Allows to know if the X-scale must be displayed
- * @return True if the X-scale must be displayed
- */
- public boolean isXScaleDisplayed()
- {
- if(displayXScale==null)
- return false;
-
- return displayXScale.isSelected();
- }
-
-
-
- /**
- * Allows to know if the Y-scale must be displayed
- * @return True if the Y-scale must be displayed
- */
- public boolean isYScaleDisplayed()
- {
- if(displayYScale==null)
- return false;
-
- return displayYScale.isSelected();
- }
-
-
-
-
- /**
- * Allows to know if the the borders of the drawing must be displayed
- * @return True if the the borders of the drawing must be displayed
- */
- public boolean isBordersDisplayed()
- {
- if(displayBorders==null)
- return false;
- return displayBorders.isSelected();
- }
-
-
-
- /**
- * Allows to know if the codePanel must be displayed
- * @return True if the codePanel must be displayed
- */
- public boolean isCodePanelDisplayed()
- {
- if(codePanel==null)
- return false;
- return codePanel.isVisible();
- }
-
-
-
-
-
- /**
- * Invoked when an action occurs.
- * @param e The action which is at the origin of the call
- */
- public void actionPerformed(ActionEvent e)
- {
- Object src = e.getSource();
-
- if(src instanceof JMenuItem || src instanceof JButton || src instanceof JToggleButton || src instanceof JCheckBox)
- {
- AbstractButton ab = ((AbstractButton)src);
- String label = ab.getActionCommand();
- Draw listSelected = drawPanel.getDraw().getSelected();
- boolean ok = ab.isSelected();
-
- try
- {
- if(label.compareTo(LABEL_FILLED_CHECKBOX)==0)
- {
- if(listSelected!=null && listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected!=null && listSelected.getNbFigures()==1)
- {
- Figure selected = listSelected.getFigureAt(0);
- selected.setIsFilled(ok && selected.canBeFilled());
- buttonInteriorColor.setVisible(((ok && selected.canBeFilled()) || selected.hasShadow()));
- buttonInteriorColor.setColor(selected.getInteriorColor());
- }
- else
- {
- genIsFilled = ok;
-
- if(listSelected!=null)
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.canBeFilled())
- f.setIsFilled(ok);
- }
-
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- requestFocus();
- return;
- }
-
- if(label.compareTo(LABEL_DBLE_BOUND_CHECKBOX)==0)
- {
- if(listSelected!=null && listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected!=null && listSelected.getNbFigures()==1)
- {
- Figure selected = listSelected.getFigureAt(0);
- selected.setHasDoubleBoundary(ok && selected.isDoubleBoundaryable());
- buttonDbleBoundColor.setVisible(ok && selected.isDoubleBoundaryable());
- }
- else
- {
- genHasDbleBord = ok;
-
- if(listSelected!=null)
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.isDoubleBoundaryable())
- f.setHasDoubleBoundary(ok);
- }
-
- if(listSelected!=null) listSelected.updateBorders();
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- requestFocus();
- return;
- }
-
- if(label.compareTo(LABEL_SHADOW_CHECKBOX)==0)
- {
- if(listSelected!=null && listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected!=null && listSelected.getNbFigures()==1)
- {
- Figure selected = listSelected.getFigureAt(0);
- selected.setHasShadow(ok && selected.canHaveShadow());
- buttonShadowColor.setVisible(ok && selected.canHaveShadow());
- buttonInteriorColor.setVisible(ok && selected.canHaveShadow() && selected.canBeFilled() && selected.shadowFillsShape() && !selected.hasGradient());
- updateFillCB();
- }
- else
- {
- genHasShadow = ok;
-
- if(listSelected!=null)
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.canHaveShadow())
- f.setHasShadow(ok);
- }
-
- if(listSelected!=null) listSelected.updateBorders();
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- requestFocus();
- return;
- }
-
- if(label.compareTo(LABEL_ROTATE)==0)
- {
- drawPanel.setOnRotation(!drawPanel.isOnRotation());
- rotateButton.setSelected(drawPanel.isOnRotation());
- drawPanel.
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_MAGNETIC_CB)==0)
- {
- drawPanel.setGridIsMagnetic(magneticCB.isSelected());
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_COLOR_HATCH)==0)
- {
- if(listSelected==null)
- return ;
-
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.150"), buttonHatchColor.getColor()); //$NON-NLS-1$
-
- if(c!=null)
- {
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- {
- buttonHatchColor.setColor(c);
- listSelected.getFigureAt(0).setHatchingColor(c);
- }
- else
- {
- genHatchCB.setColor(c);
- genHatchC = c;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.canBeHatched())
- f.setHatchingColor(c);
- }
-
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- }
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_COLOR_GRADIENT_FIRST)==0)
- {
- if(listSelected==null)
- return ;
-
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getString1_7("LaTeXDrawFrame.7"), buttonGradientStartC.getColor()); //$NON-NLS-1$
-
- if(c!=null)
- {
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- {
- buttonGradientStartC.setColor(c);
- listSelected.getFigureAt(0).setGradientStartColor(c);
- }
- else
- {
- genGradientStartCB.setColor(c);
- genGradientStartC = c;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.canBeHatched())
- f.setGradientStartColor(c);
- }
-
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- }
-
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_COLOR_GRADIENT_SECOND)==0)
- {
- if(listSelected==null)
- return ;
-
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getString1_7("LaTeXDrawFrame.8"), buttonGradientEndC.getColor()); //$NON-NLS-1$
-
- if(c!=null)
- {
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- {
- buttonGradientEndC.setColor(c);
- listSelected.getFigureAt(0).setGradientEndColor(c);
- }
- else
- {
- genGradientEndCB.setColor(c);
- genGradientEndC = c;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.canBeHatched())
- f.setGradientEndColor(c);
- }
-
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- }
-
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_COLOR_DBLE_BOUND)==0)
- {
- if(listSelected==null)
- return ;
-
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.151"), buttonDbleBoundColor.getColor()); //$NON-NLS-1$
-
- if(c!=null)
- {
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- {
- buttonDbleBoundColor.setColor(c);
- Figure selected = listSelected.getFigureAt(0);
- selected.setDoubleColor(c);
- }
- else
- {
- genDbleBordCB.setColor(c);
- genDbleC = c;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.isDoubleBoundaryable())
- f.setDoubleColor(c);
- }
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- }
-
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_COLOR_SHADOW)==0)
- {
- if(listSelected==null)
- return ;
-
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getString1_7("LaTeXDrawFrame.9"), buttonShadowColor.getColor()); //$NON-NLS-1$
-
- if(c!=null)
- {
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- {
- buttonShadowColor.setColor(c);
- listSelected.getFigureAt(0).setShadowColor(c);
- }
- else
- {
- genShadowCB.setColor(c);
- genShadowC = c;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.canHaveShadow())
- f.setShadowColor(c);
- }
-
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- }
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_COLOR_BUTTON)==0)
- {
- if(listSelected==null)
- return ;
-
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.152"), ((ColorButton)src).getColor()); //$NON-NLS-1$
-
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(c!=null)
- {
- if(listSelected.getNbFigures()==1)
- listSelected.getFigureAt(0).setLinesColor(c);
- else
- {
- genLineC = c;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable())
- f.setLinesColor(c);
- }
-
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- ((ColorButton)src).setColor(c);
- }
-
- requestFocus();
- return ;
- }
-
-
- if(label.compareTo(LABEL_COLOR_INTERIOR_BUTTON)==0)
- {
- if(listSelected==null)
- return ;
-
- Color c = JColorChooser.showDialog((Component) e.getSource(),
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.153"), ((ColorButton)src).getColor()); //$NON-NLS-1$
-
- if(c!=null)
- {
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- listSelected.getFigureAt(0).setInteriorColor(c);
- else
- {
- genInteriorC = c;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.canBeFilled())
- f.setInteriorColor(c);
- }
-
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- ((ColorButton)src).setColor(c);
- }
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_JOIN)==0)
- {
- drawPanel.joinSelection(undoManager);
- updateUndoRedo();
- setSelection(true);
- setIsModified(true);
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.154")); //$NON-NLS-1$
- requestFocus();
- return;
- }
-
- if(label.compareTo(LABEL_SEPARATE)==0)
- {
- drawPanel.separateSelection(undoManager);
- updateUndoRedo();
- setSelection(true);
- setIsModified(true);
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.155")); //$NON-NLS-1$
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_BEHIND_SEL)==0)
- {
- setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
- drawPanel.setOnWaitingClicDispositionBehind(true);
- requestFocus();
- return;
- }
-
- if(label.compareTo(LABEL_FRONT_SEL)==0)
- {
- setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
- drawPanel.setOnWaitingClicDispositionFront(true);
- requestFocus();
- return;
- }
-
- if(label.compareTo(LABEL_BACKGROUND)==0)
- {
- drawPanel.selectedInBackground();
- setIsModified(true);
- requestFocus();
- return;
- }
-
- if(label.compareTo(LABEL_FOREGROUND)==0)
- {
- drawPanel.selectedInForeground();
- setIsModified(true);
- requestFocus();
- return;
- }
-
- if(label.compareTo(LABEL_ROTATE_90)==0)
- {
- drawPanel.draw.rotateSelection(Math.PI/2.);
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_ROTATE_180)==0)
- {
- drawPanel.draw.rotateSelection(Math.PI);
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_ROTATE_270)==0)
- {
- drawPanel.draw.rotateSelection(3*Math.PI/2.);
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_MIRROR_H)==0)
- {
- drawPanel.draw.mirrorHorizontal();
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_MIRROR_V)==0)
- {
- drawPanel.draw.mirrorVertical();
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_TEX_EDITOR)==0)
- {
- String title = LaTeXDrawLang.getString1_8("LaTeXDrawFrame.19"); //$NON-NLS-1$
-
- if(pathTexEditor==null || pathTexEditor.length()==0)
- JOptionPane.showMessageDialog(this, LaTeXDrawLang.getString1_8("LaTeXDrawFrame.20"), //$NON-NLS-1$
- title, JOptionPane.WARNING_MESSAGE);
- else
- try{Runtime.getRuntime().exec(pathTexEditor);}
- catch(Exception ex)
- {
- JOptionPane.showMessageDialog(this,
- "<html>"+LaTeXDrawLang.getString1_8("LaTeXDrawFrame.21")+"<br>"+//$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
- LaTeXDrawLang.getString1_8("LaTeXDrawFrame.22")+"</html>", //$NON-NLS-1$//$NON-NLS-2$
- title, JOptionPane.WARNING_MESSAGE);
- }
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_STOP)==0)
- {
- if(parsingThread!=null) texParser.stop();
- stopButton.setVisible(false);
- progressBar.setVisible(false);
- requestFocus();
- return ;
- }
-
- if(label.compareTo(TEMPLATE_START_ACTION_CMD)>0)
- {
- String str = label.substring(TEMPLATE_START_ACTION_CMD.length());
- boolean fromShared = str.charAt(0)=='0' ? false : true;
-
- Draw template = readTemplate(str.substring(1)+TEMPLATE_EXTENSION, fromShared);
-
- if(template!=null)
- {
- template.setDrawFigures(true);
- template.setSelected(false);
-
- if(template.getNbFigures()==0)
- return ;
-
- drawPanel.getDraw().addFigure(template.getNbFigures()>1 ? template : template.getFigureAt(0), undoManager);
- updateUndoRedo();
- drawPanel.updateDraw(true);
- }
- else
- {
- JOptionPane.showMessageDialog(this,
- "<html>"+"This template cannot be found"+"<br>"+"Please, update the templates menu"+"</html>",//$NON-NLS-1$//$NON-NLS-3$//$NON-NLS-5$
- "Template not found", JOptionPane.WARNING_MESSAGE);
- }
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_TEMPLATE_UPDATE)==0)
- {
- menuTemplate.updateTemplates();
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.160")); //$NON-NLS-1$
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_COMMENTS)==0)
- {
- addCommentsFrame.setVisible(true);
- return;
- }
-
-
- if(label.compareTo(LABEL_PREFERENCES)==0)
- {
- if(!preferencesFrame.isVisible())
- preferencesFrame.setVisible(true);
-
- return ;
- }
-
- if(label.compareTo(LABEL_INSERT_CODE)==0)
- {
- if(insertCodeFrame==null)
- insertCodeFrame = new InsertPSTricksCodeFrame(this);
-
- insertCodeFrame.setVisible(true);
- requestFocus();
- return ;
- }
-
- if(label.compareTo(LABEL_DRAW_PROPERTIES)==0)
- {
- if(drawPropertiesFrame==null)
- drawPropertiesFrame = new DrawPropertiesFrame(this);
-
- drawPropertiesFrame.setVisible(true);
- return ;
- }
-
- if(label.compareTo(LABEL_HELP)==0)
- {
- if(helpFrame==null)
- createHelpFrame();
-
- if(helpFrame!=null)
- helpFrame.setVisible(true);
-
- return;
- }
-
- if(label.compareTo(LABEL_DISPLAY_GRID)==0)
- {
- if(displayGrid.isSelected())
- {
- displayPersoGrid.setSelected(false);
- persoGridGapField.setEnabled(false);
- }
-
- displayGrid(displayGrid.isSelected(), displayGrid.isSelected());
- return;
- }
-
- if(label.compareTo(LABEL_DISPLAY_PERSO_GRID)==0)
- {
- if(displayPersoGrid.isSelected())
- {
- displayGrid.setSelected(false);
- persoGridGapField.setEnabled(true);
- }
-
- displayGrid(displayPersoGrid.isSelected(), !displayPersoGrid.isSelected());
- return;
- }
-
- if(label.compareTo(LABEL_ABOUT)==0)
- {
- if(aboutTeXDraw==null)
- createAboutTeXDrawFrame();
-
- aboutTeXDraw.setVisible(true);
- return;
- }
-
- if(label.compareTo(LABEL_DISPLAY_CODE_PANEL)==0)
- {
- if(!(e.getSource() instanceof JCheckBoxMenuItem))
- displayCodePanel.setSelected(!displayCodePanel.isSelected());
-
- displayCodePanel(displayCodePanel.isSelected());
- requestFocus();
- return;
- }
-
- }catch(Exception ex)
- {
- ex.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ex);
- }
- } // if(src instanceof JMenuItem || src instanceof JButton)
- }
-
-
-
-
- /**
- * To launch when the selected figures are transformed : add an undo.
- * @param listSelected THe list of the selected figures.
- * @since 1.9.1
- */
- private void addToUndoTransformation(Draw listSelected)
- {
- try
- {
- Object clone = listSelected.clone();
- Vector<Figure> figures = drawPanel.draw.getFigures();
- int i, size = listSelected.getNbFigures();
- int[] id = new int[size];
-
- for(i=0; i<size; i++)
- id[i] = figures.indexOf(listSelected.getFigureAt(i));
-
- undoManager.add(UndoRedoManager.LABEL_TRANSFORM, id, clone, false);
- updateUndoRedo();
-
- }catch(CloneNotSupportedException e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- }
-
-
-
- /**
- * Allows to get the figures from a templates.<br>
- * 09/07/06: fix #1553683
- * @param name The name of the file containing the template
- * @param shared True if the template comes from the shared templates directory.
- * @return The figures
- */
- public Draw readTemplate(String name, boolean shared)
- {
- if(shared)
- return LaTeXDrawPath.PATH_TEMPLATES_SHARED==null ? null :
- readTemplate(new File(LaTeXDrawPath.PATH_TEMPLATES_SHARED+File.separator+name));
-
- return readTemplate(new File(LaTeXDrawPath.PATH_TEMPLATES_DIR_USER+File.separator+name));
- }
-
-
-
-
- /**
- * Allows to get the figures from a templates
- * @param file The file containing the template
- * @return The figures
- */
- public Draw readTemplate(File file)
- {
- try
- {
- Draw template;
- FileInputStream fis = new FileInputStream(file);
- ObjectInputStream in = new ObjectInputStream(fis);
- String nameApp = (String)in.readObject();
-
- if(nameApp.compareTo(TOKEN_TEMPLATE_FILE)!=0)
- throw new LaTeXDrawException(LaTeXDrawException.NOT_TEXDRAW_FILE);
-
- versionOfFile = (String)in.readObject();
-
- if(VERSION.compareTo(versionOfFile)<0)
- throw new LaTeXDrawException(LaTeXDrawException.INVALID_TEXDRAW_VERSION);
-
- template = (Draw)in.readObject();
- in.close();
- fis.close();
-
- return template;
-
- }catch(LaTeXDrawException e)
- {
- JOptionPane.showMessageDialog(this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.161")//$NON-NLS-1$
- + file.getAbsolutePath()+", "+e.toString(), //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.86"), //$NON-NLS-1$
- JOptionPane.WARNING_MESSAGE);
- return null;
- }catch(Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- return null;
- }
- }
-
-
-
-
- /**
- * Allows to print the draw
- */
- public void printDraw()
- {
- PrinterJob printJob = PrinterJob.getPrinterJob();
- printJob.setPrintable(drawPanel.getDraw());
-
- System.setProperty("sun.java2d.print.pipeline", "pdl");//$NON-NLS-1$ //$NON-NLS-2$
-
- if (printJob.printDialog())
- {
- try
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.162")); //$NON-NLS-1$
- printJob.print();
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.163")); //$NON-NLS-1$
- }
- catch(Exception e)
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.164")); //$NON-NLS-1$
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- }
- }
-
-
-
-
- public void printCode()
- {
- drawPanel.updateCode();
-
- PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
- DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
- PrintService printService[] = PrintServiceLookup.lookupPrintServices(null, null);
- PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
-
- if(printService!=null && printService.length!=0)
- {
- if(defaultService==null)
- defaultService = printService[0];
-
- PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, null, pras);
-
- if(service != null)
- {
- DocPrintJob job = service.createPrintJob();
- Doc doc = new SimpleDoc(codePanel.getText().getBytes(), flavor, null);
-
- try { job.print(doc, pras); }
- catch(PrintException ex) { JOptionPane.showMessageDialog(this, "The document cannot be printed."); }
- }
- }
- else
- setStatusBarText("No printer has been found.");
- }
-
-
-
- /**
- * Allows to export the selected figures as a template in a file.
- */
- public void exportAsTemplate()
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.168")); //$NON-NLS-1$
- String templateName = drawPanel.exportSelectionAsTemplate();
-
- if(templateName!=null)
- {
- menuTemplate.addItem(templateName);
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.169")); //$NON-NLS-1$
- }
- else
- setStatusBarText("");//$NON-NLS-1$
- }
-
-
-
- /**
- * Allows to insert several figures from PSTricks code into the current draw
- * @param code The code to parse and to convert in figures
- */
- public void insertPSTricksCode(String code)
- {
- try
- {
- String code2 = code;
-
- if(code2!=null && code2.length()!=0)
- {
- if(PSTricksParser.containsBeginPSPicture(code2)==0)
- {
- String eol = System.getProperty("line.separator"); //$NON-NLS-1$
- code2 = "\\begin{pspicture}(10,10)"+eol+code2+eol+"\\end{pspicture}";//$NON-NLS-1$ //$NON-NLS-2$
- }
-
- progressBar.setMinimum(0);
- progressBar.setVisible(true);
- stopButton.setVisible(true);
- codeToParse = code2;
-
- parsingThread = new Thread(this);
- parsingThread.start();
- }
- }catch(Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
-
- }
-
-
-
-
-
-
-
- /**
- * Allows to import a TeXFile.
- */
- public void importPSTricksFile()
- {
- currentFile = null;
- projectName = null;
- setTitle();
- try
- {
- if(fileChooserImport==null)
- {
- fileChooserImport = new PictureChooser(this, LaTeXDrawLang.getString1_6("LaTeXDrawFrame.16"), //$NON-NLS-1$
- false, LaTeXDrawLang.getString1_6("LaTeXDrawFrame.17")); //$NON-NLS-1$
-
- JFileChooser fileChooser = fileChooserImport.getFileChooser();
- if(pathExport!=null)
- fileChooser.setCurrentDirectory(new File(pathExport));
- fileChooser.setApproveButtonText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.199")); //$NON-NLS-1$
- fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- fileChooser.setAcceptAllFileFilterUsed(false);
- fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- fileChooser.addChoosableFileFilter(new TeXFilter());
- fileChooser.setFileHidingEnabled(true);
- fileChooser.setApproveButtonText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.171")); //$NON-NLS-1$
- fileChooser.setMultiSelectionEnabled(false);
- }
-
- File file = fileChooserImport.displayFrame();
-
- if(file==null) return;
-
- importPSTricksFile(file.getAbsolutePath());
-
- }catch (Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- }
-
-
-
-
- /**
- * Allows to import a TeXFile with the filename given.
- */
- public boolean importPSTricksFile(String path)
- {
- try
- {
- File file = new File(path);
-
- if(!file.exists() || !file.canRead() || !file.isFile())
- return false;
-
- setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.15")); //$NON-NLS-1$
-
- reinitializeButtons();
- preferencesFrame.addRecentFile(file.getAbsolutePath());
- updateRecentFilesMenu();
- setIsModified(false);
- newProject();
- undoManager = new UndoRedoManager(drawPanel.getDraw().getFigures(), drawPanel.getDraw(), this);
- updateUndoRedo();
- fileToParse = file;
- parsingThread = new Thread(this);
- parsingThread.start();
-
- return true;
-
- }catch (Exception e)
- {
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- return false;
- }
- }
-
-
-
-
- /**
- * Allows to export the pstricks code as a .tex file
- */
- public void exportAsPsTricks()
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.170")); //$NON-NLS-1$
-
- if(fileChooserExport==null)
- fileChooserExport = new ExportDialog(currentFile==null ? pathExport : currentFile.getPath());
-
- fileChooserExport.removeChoosableFileFilter(fileChooserExport.getFileFilter());
- fileChooserExport.setFileFilter(fileChooserExport.getAcceptAllFileFilter());
- fileChooserExport.setFileFilter(new TeXFilter());
- fileChooserExport.setDialogTitle(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.172")); //$NON-NLS-1$
-
- int res = fileChooserExport.showSaveDialog(this);
- File file = fileChooserExport.getSelectedFile();
-
- if(res != JFileChooser.APPROVE_OPTION || file==null)
- {
- setStatusBarText("");//$NON-NLS-1$
- return;
- }
-
- projectName = file.getName();
- String ex = TeXFilter.TEX_EXTENSION;
- int id = projectName.toLowerCase().indexOf(ex.toLowerCase());
-
- if(id ==-1)
- file = new File(file.getPath() + TeXFilter.TEX_EXTENSION);
-
- if(file.exists())
- {
- int replace = JOptionPane.showConfirmDialog(this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.173"), //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.174"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
-
-
- if(replace == JOptionPane.NO_OPTION)
- return; // The user doesn't want to replace the file
- }
-
- PrintWriter out=null;
-
- try // We export the code
- {
- FileWriter fw = new FileWriter(file);
- BufferedWriter bw = new BufferedWriter(fw);
- out = new PrintWriter(bw);
-
- drawPanel.updateCode();
- out.println(codePanel.getText());
- out.close();
- bw.close();
- fw.close();
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.175")); //$NON-NLS-1$
- }
- catch (Exception e)
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.176")); //$NON-NLS-1$
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
-
- if(out!=null)
- out.close();
- setTitle();
- }
-
-
-
-
- public void exportAsPicture(String format)
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.177")); //$NON-NLS-1$
-
- if(fileChooserExport==null)
- fileChooserExport = new ExportDialog(currentFile==null ? pathExport : currentFile.getPath());
-
- fileChooserExport.removeChoosableFileFilter(fileChooserExport.getFileFilter());
- fileChooserExport.setFileFilter(fileChooserExport.getAcceptAllFileFilter());
-
- if(format.compareTo(LABEL_EXPORT_EPS)==0)
- fileChooserExport.setFileFilter(new EPSFilter());
- else
- if(format.compareTo(LABEL_EXPORT_JPG)==0)
- fileChooserExport.setFileFilter(new JPGFilter());
- else
- if(format.compareTo(LABEL_EXPORT_PNG)==0)
- fileChooserExport.setFileFilter(new PNGFilter());
- else
- if(format.compareTo(LABEL_EXPORT_BMP)==0)
- fileChooserExport.setFileFilter(new BMPFilter());
- else
- if(format.compareTo(LABEL_EXPORT_PPM)==0)
- fileChooserExport.setFileFilter(new PPMFilter());
- else
- return ;
-
- fileChooserExport.setDialogTitle(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.179")+format +LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.183")); //$NON-NLS-1$ //$NON-NLS-2$
-
- int response = fileChooserExport.showSaveDialog(this);
- File file = fileChooserExport.getSelectedFile();
-
- if(response != JFileChooser.APPROVE_OPTION || file==null)
- return;
-
- String name = file.getName(), ex;
-
- if(format.compareTo(LABEL_EXPORT_EPS)==0)
- ex = EPS_EXTENSION;
- else if(format.compareTo(LABEL_EXPORT_JPG)==0)
- ex = JPG_EXTENSION;
- else if(format.compareTo(LABEL_EXPORT_BMP)==0)
- ex = BMP_EXTENSION;
- else if(format.compareTo(LABEL_EXPORT_PNG)==0)
- ex = PNG_EXTENSION;
- else ex = PPM_EXTENSION;
-
- int id = name.toLowerCase().indexOf(ex.toLowerCase());
-
- if(id ==-1)
- file = new File(file.getPath() + ex);
-
- if(file.exists())
- {
- int replace = JOptionPane.showConfirmDialog(this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.181"), //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.182")+format+LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.183"), //$NON-NLS-1$ //$NON-NLS-2$
- JOptionPane.YES_NO_OPTION);
-
-
- if(replace == JOptionPane.NO_OPTION)
- return; // The user doesn't want to replace the file
- }
-
-
- try
- {
- int compressionRate = fileChooserExport.getCompressionRate();
- drawPanel.exportAsPicture(file, format, compressionRate==-1 ? ExportDialog.DEFAULT_COMPRESSION_RATE :
- 1.f-compressionRate/100.f);
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.184")); //$NON-NLS-1$
- }
- catch(Exception e)
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.185")); //$NON-NLS-1$
- e.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(e);
- }
- }
-
-
-
-
-
-
-
- /**
- * Shutdown procedure when run as an application.
- */
- protected void windowClosed()
- {
- System.exit(0);
- }
-
-
-
-
- /**
- * Define actions to do when a key is released
- * @param e The event
- */
- public void stateChanged(ChangeEvent e)
- {
- Object src = e.getSource();
- String name = ((Component)src).getName();
-
- if(src instanceof JSpinner)
- {
- Draw selection = drawPanel.getDraw().getSelected();
-
- if(name.compareTo(NAME_THICKNESS_FIELD)==0)
- {
- float thick = Float.valueOf(thicknessField.getValue().toString()).floatValue();
-
- if(selection!=null && selection.getNbFigures()==1)
- selection.getFigureAt(0).setThickness(thick);
- else
- {
- if(selection!=null)
- for(Figure f : selection.getFigures())
- if(f.isCustomizable() && f.isThicknessable())
- f.setThickness(thick);
-
- genThickness = thick;
- }
-
- if(selection!=null) selection.updateBorders();
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- thicknessField.requestFocus();
-
- return;
- }
-
- if(name.compareTo(NAME_DOT_SIZE_FIELD)==0)
- {
- float size = Float.valueOf(dotSizeField.getValue().toString()).floatValue();
-
- if(selection!=null && selection.getNbFigures()==1 && selection.getFigureAt(0) instanceof Dot)
- ((Dot)selection.getFigureAt(0)).setWidth(size);
- else
- {
- if(selection!=null)
- for(Figure f : selection.getFigures())
- if(f instanceof Dot)
- ((Dot)f).setWidth(size);
-
- genDotSize = size;
- }
-
- if(selection!=null) selection.updateBorders();
- drawPanel.updateDraw(true);
- drawPanel.setIsModified(true);
- dotSizeField.requestFocus();
-
- return;
- }
-
- if(name.compareTo(LABEL_PERSO_GRID_GAP_FIELD)==0)
- {
- drawPanel.getDraw().setPersonalGridGap(Integer.valueOf(persoGridGapField.getValue().toString()).intValue());
- drawPanel.setIsModified(true);
- return ;
- }
- return ;
- }
-
- if(src instanceof JSlider)
- {
- JSlider slider = (JSlider)src;
-
- if(name.compareTo(NAME_SLIDER_DELIMITOR)==0)
- {
- Delimitor.setOpacity(slider.getValue());
- drawPanel.draw.repaint();
- return ;
- }
- return ;
- }
- }
-
-
-
-
-
- /**
- * Allows to save the current project in a file
- */
- public boolean save(boolean saveAs)
- {
- // It's useless to save the project if it hasn't been modified
- try
- {
- if(!saveAs && !drawPanel.isModified() && currentFile==null)
- return true;
- }catch(Exception ex)
- {
- ex.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ex);
- }
-
- File file;
- boolean addToRecent = false;
-
- // If the user want to "save as" or if he hasn't ever
- // save his project, we display a dialog box in order to select a file
- if(saveAs || currentFile==null)
- {
- if(fileChooserSave==null)
- {
- fileChooserSave = new JFileChooser(pathOpen);
- fileChooserSave.setFileSelectionMode(JFileChooser.FILES_ONLY);
- fileChooserSave.setApproveButtonText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.187")); //$NON-NLS-1$
- }
- fileChooserSave.setDialogTitle(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.188"));//$NON-NLS-1$
- fileChooserSave.addChoosableFileFilter(new LaTeXDrawFilter());
- fileChooserSave.setMultiSelectionEnabled(false);
-
- int response = fileChooserSave.showSaveDialog(this);
-
- if(response != JFileChooser.APPROVE_OPTION)
- return false;
-
- file = fileChooserSave.getSelectedFile();
- if(file==null)
- return false;
-
- // Creation of the name of the project
- projectName = file.getName();
- String ex = PROJECT_EXTENSION;
- int id = projectName.toLowerCase().indexOf(ex.toLowerCase());
-
- if(id ==-1)
- file = new File(file.getPath() + PROJECT_EXTENSION);
- else
- {
- char[] dst = new char[id];
- projectName.getChars(0, id, dst, 0);
- projectName = String.valueOf(dst);
-
- }
-
- if(file.exists())
- {
- int replace = JOptionPane.showConfirmDialog(this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.189"), //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.190"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
-
- if(replace == JOptionPane.NO_OPTION) return false;
- }
- currentFile = file;
- addToRecent = true;
- }
- else file = currentFile;
-
-
- try // We save the project in the file
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.186")); //$NON-NLS-1$
-
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
-
- out.writeObject(LABEL_APP);
- out.writeObject(VERSION);
- out.writeBoolean(codePanel.isInAutoUpdate());
- out.writeBoolean(formerIsInAutoUpdate);
- out.writeBoolean(displayBorders.isSelected());
- out.writeBoolean(autoAdjustBorders.isSelected());
- drawPanel.draw.save(out);
- out.writeObject(getPreferredSize());
- out.writeObject(getLocation());
- out.writeInt(splitPane.getDividerLocation());
- out.writeBoolean(displayCodePanel.isSelected());
- out.writeBoolean(drawPanel.isGridDisplayed());
- out.writeBoolean(displayXScale.isSelected());
- out.writeBoolean(displayYScale.isSelected());
- out.writeObject(codePanel.getCommentsWithoutPercent());
-
- out.writeObject(codePanel.getLabel()); // since 1.6
- out.writeObject(codePanel.getCaption());
- out.writeObject(codePanel.getPositionHoriToken());
- out.writeObject(codePanel.getPositionVertToken());
-
- out.writeBoolean(drawPanel.isGridMagnetic());
- out.writeBoolean(drawPanel.draw.isClassicGridDrawn());
- out.writeInt(drawPanel.draw.getPersonalGridGap());
-
- out.writeInt(Delimitor.getOpacity());
- out.close();
-
- setTitle();
- if(addToRecent)
- {
- preferencesFrame.addRecentFile(file.getAbsolutePath());
- updateRecentFilesMenu();
- }
- drawPanel.setIsModified(false);
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.191")); //$NON-NLS-1$
- }catch(Exception e)
- {
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.192"));//$NON-NLS-1$
- e.printStackTrace();
- JOptionPane.showMessageDialog(this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.193") +e.toString(), //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.194"), //$NON-NLS-1$
- JOptionPane.WARNING_MESSAGE);
- }
-
- return true;
- }
-
-
-
-
- public void newProject()
- {
- try
- {
- if(drawPanel.isModified())
- switch(JOptionPane.showConfirmDialog(this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.206"), //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.207"), //$NON-NLS-1$
- JOptionPane.YES_NO_CANCEL_OPTION))
- {
- case JOptionPane.YES_OPTION:
- boolean saved = save(false);
- if(!saved) return;
- break;
- case JOptionPane.NO_OPTION:
- break;
- case JOptionPane.CANCEL_OPTION:
- return;
- }
-
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.197")); //$NON-NLS-1$
- setTitle(LABEL_APP);
- drawPanel.newProject();
- undoManager = new UndoRedoManager(drawPanel.getDraw().getFigures(), drawPanel.getDraw(), this);
- reinitializeButtons();
- setSelection(false);
- currentFile = null;
- drawPanel.getDraw().setIsModified(false);
- xScale.repaint();
- yScale.repaint();
- setExportAsMenu(false);
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.198")); //$NON-NLS-1$
-
- }catch(Exception ex)
- {
- ex.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ex);
- }
- }
-
-
-
-
- /**
- * Allows to load a saved project
- */
- public boolean open(String fileName, boolean withDialog)
- {
- File file;
- if(fileName==null)
- {
- if(fileChooserSave==null)
- {
- fileChooserSave = new JFileChooser(pathOpen);
- fileChooserSave.setApproveButtonText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.199")); //$NON-NLS-1$
- fileChooserSave.setFileSelectionMode(JFileChooser.FILES_ONLY);
- fileChooserSave.addChoosableFileFilter(new LaTeXDrawFilter());
- fileChooserSave.setMultiSelectionEnabled(false);
- }
-
- fileChooserSave.setDialogTitle(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.200")); //$NON-NLS-1$
-
- int id = fileChooserSave.showSaveDialog(this);
-
- if(id != JFileChooser.APPROVE_OPTION)
- return false;
-
- file = fileChooserSave.getSelectedFile();
- if(file==null)
- return false;
- }
- else
- file = new File(fileName);
-
- currentFile = file;
- reinitializeButtons();
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.201")); //$NON-NLS-1$
- projectName = file.getName();
- setExportAsMenu(true);
- String ext = PROJECT_EXTENSION;
- int id = projectName.toLowerCase().indexOf(ext.toLowerCase());
-
- if(id !=-1)
- {
- char[] dst = new char[id];
- projectName.getChars(0, id, dst, 0);
- projectName = String.valueOf(dst);
-
- }
-
-
- if(file.exists() && file.isFile() && file.canRead())
- {
- try
- {
- ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
- DrawContainer draw;
-
- if(LABEL_APP.compareTo((String)in.readObject())!=0)
- new LaTeXDrawException(LaTeXDrawException.NOT_TEXDRAW_FILE);
-
- versionOfFile = (String)in.readObject();
- if(VERSION.compareTo(versionOfFile)>0)
- new LaTeXDrawException(LaTeXDrawException.INVALID_TEXDRAW_VERSION);
-
- boolean autoUpd = in.readBoolean();
- formerIsInAutoUpdate = in.readBoolean();
- boolean displayB = in.readBoolean();
- autoAdjustBorders.setSelected(in.readBoolean());
-
- if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.9.3")>=0) //$NON-NLS-1$
- {
- draw = new DrawContainer();
- draw.open(in);
- }
- else
- draw = (DrawContainer)in.readObject();
-
- drawPanel.setDraw(draw);
- draw = drawPanel.getDraw();
- draw.isSelection(false);
- sliderDelimitor.setValue(Delimitor.getOpacity());
- displayBorders.setSelected(displayB);
- draw.setParentPanel(drawPanel);
- draw.setAutoAdjustement(autoAdjustBorders.isSelected());
- draw.displayBorders(displayB);
- undoManager.setFigures(draw.getFigures());
- setPreferredSize((Dimension)in.readObject());
- setLocation((Point)in.readObject());
- splitPane.setDividerLocation(in.readInt());
- displayCodePanel(in.readBoolean());
- codePanel.setIsInAutoUpdate(autoUpd);
- Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
- formerDividerLocation=(int)(dim.width*0.7);
- formerIsInAutoUpdate = !isCodePanelDisplayed();
- buttonImageBorders.setSelected(displayBorders.isSelected());
- drawPanel.setIsGridDisplay(in.readBoolean());
- displayXScale.setSelected(in.readBoolean());
- displayYScale.setSelected(in.readBoolean());
- codePanel.setComments((String) in.readObject());
-
- if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.6")>=0) //$NON-NLS-1$
- {
- codePanel.setLabel((String)in.readObject());
- codePanel.setCaption((String)in.readObject());
- codePanel.setPositionHoriToken((String)in.readObject());
- codePanel.setPositionVertToken((String)in.readObject());
- }
-
- if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.8")>=0) //$NON-NLS-1$
- {
- drawPanel.setGridIsMagnetic(in.readBoolean());
- magneticCB.setSelected(drawPanel.isGridMagnetic());
- boolean isClassicGrid = in.readBoolean();
- displayGrid.setSelected(isClassicGrid && drawPanel.isGridDisplayed());
- displayPersoGrid.setSelected(!isClassicGrid && drawPanel.isGridDisplayed());
- persoGridGapField.setEnabled(displayPersoGrid.isSelected());
- drawPanel.draw.setClassicGridDrawn(isClassicGrid);
- drawPanel.draw.setPersonalGridGap(in.readInt());
- persoGridGapField.setValue(drawPanel.draw.getPersonalGridGap());
- }
- else
- {
- displayGrid.setSelected(drawPanel.isGridDisplayed());
- displayPersoGrid.setSelected(false);
- persoGridGapField.setEnabled(false);
- }
-
- if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.9")>=0) //$NON-NLS-1$
- {
- Delimitor.setOpacity(in.readInt());
- sliderDelimitor.setValue(Delimitor.getOpacity());
- }
-
- drawPanel.updateDraw(true);
- in.close();
-
- setTitle();
- undoManager = new UndoRedoManager(drawPanel.getDraw().getFigures(), drawPanel.getDraw(), this);
- updateUndoRedo();
- setSelection(false);
- setIsModified(false);
- preferencesFrame.addRecentFile(file.getAbsolutePath());
- updateRecentFilesMenu();
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.202")); //$NON-NLS-1$
- }
- catch(InvalidClassException ex)
- {
- currentFile = null;
- setIsModified(false);
-
- if(withDialog)
- JOptionPane.showMessageDialog(this, LaTeXDrawLang.getString1_9("LaTeXDrawFrame.12"), //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.194"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
- return false;
- }
- catch(Exception ex)
- {
- currentFile = null;
- setIsModified(false);
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.203")); //$NON-NLS-1$
- ex.printStackTrace();
-
- if(withDialog)
- JOptionPane.showMessageDialog(this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.204") + ex.toString(), //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.194"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
- return false;
- }
- }
- else
- {
- currentFile = null;
- setIsModified(false);
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.203")); //$NON-NLS-1$
-
- if(withDialog)
- JOptionPane.showMessageDialog(this, "Impossible to open the file.",
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.194"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
- return false;
- }
-
- return true;
- }
-
-
-
- /**
- * Allows to create and display a dialog box which ask to
- * the user if he wants to save his project or not
- * @return JOptionPane.YES_OPTION or JOptionPane.NO_OPTION
- */
- private int dialogConfirmSave()
- {
- return (JOptionPane.showConfirmDialog(this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.206"), //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.207"), JOptionPane.YES_NO_CANCEL_OPTION)); //$NON-NLS-1$
- }
-
-
-
-
- /**
- * Allows to create the frame which contains to LaTeXDraw help
- */
- private void createHelpFrame()
- {
- try
- {
- JPanel pHelp = new JPanel(new BorderLayout());
- final JEditorPane htmlPageEditor = new JEditorPane();
- htmlPageEditor.setEditable(false);
- URL helpURL = getClass().getResource("/help/index.html");//$NON-NLS-1$
- htmlPageEditor.setPage(helpURL);
- helpFrame = new JFrame();
- Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
-
- setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.214")); //$NON-NLS-1$
- htmlPageEditor.addHyperlinkListener(new HyperlinkListener()
- {
- public void hyperlinkUpdate(HyperlinkEvent event)
- {
- if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
- try { htmlPageEditor.setPage(event.getURL()); }
- catch(IOException ioe)
- {
- ioe.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ioe);
- }
- }
- });
-
- JScrollPane scrollPane = new JScrollPane (htmlPageEditor);
- scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
-
- pHelp.add(scrollPane);
- helpFrame.getContentPane().add(pHelp, BorderLayout.CENTER);
-
- helpFrame.setSize(dim.width,dim.height);
- helpFrame.setLocation(0, 0);
- helpFrame.setResizable(true);
- helpFrame.setTitle(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.215")); //$NON-NLS-1$
- helpFrame.setVisible(false);
-
- helpFrame.setIconImage(Toolkit.getDefaultToolkit().getImage(
- getClass().getClassLoader().getResource("res/help3.gif")));//$NON-NLS-1$
-
- }catch(Exception ex)
- {
- JOptionPane.showMessageDialog(this,
- LaTeXDrawLang.getString1_9("LaTeXDrawFrame.13"), //$NON-NLS-1$
- LaTeXDrawLang.getString1_9("LaTeXDrawFrame.14"), //$NON-NLS-1$
- JOptionPane.WARNING_MESSAGE);
- }
-
- }
-
-
-
-
-
- /**
- * Allows to create the "About LaTeXDraw" box
- */
- private void createAboutTeXDrawFrame()
- {
- Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
- aboutTeXDraw = new JFrame();
- JTabbedPane tabbedPane = new JTabbedPane();
- JPanel p2 = new JPanel(), panel = new JPanel();
- JButton okB = new JButton(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.23")); //$NON-NLS-1$
-
- aboutTeXDraw.setTitle(LABEL_ABOUT);
- aboutTeXDraw.setLocation(dim.width*1/4, dim.height*1/16);
-
- Image i = Toolkit.getDefaultToolkit().getImage(
- getClass().getClassLoader().getResource("res/LaTeXDrawSmall.png"));//$NON-NLS-1$
- MediaTracker tracker=new MediaTracker(this);
- tracker.addImage(i,0);
- try { tracker.waitForID(0); }
- catch(InterruptedException e) { e.printStackTrace(); }
-
- p2.add(new DisplayCanvas(i));
-
- try
- {
- JEditorPane editorPane = new JEditorPane();
- editorPane.setEditable(false);
- editorPane.setDragEnabled(true);
-
- editorPane.setContentType("text/html");//$NON-NLS-1$
- editorPane.setBackground(tabbedPane.getBackground());
- editorPane.setText("<html><body><div style=\"text-align: center; \"><font size=\"-1\"><br>"+ //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.218")+"<br>"+//$NON-NLS-1$//$NON-NLS-2$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.219")+//$NON-NLS-1$
- VERSION +LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.220") + ID_BUILD+"<br><br>"+//$NON-NLS-1$//$NON-NLS-2$
- LABEL_APP+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.221")+"<br>"+//$NON-NLS-1$//$NON-NLS-2$
- "Copyright(c) 2005-2007 - Arnaud BLOUIN - arno_b at users.sourceforge.net<br><br>"+//$NON-NLS-1$
- "http://latexdraw.sourceforge.net/<br></div></body></html>");//$NON-NLS-1$
-
- tabbedPane.add(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.24"), new JScrollPane(editorPane)); //$NON-NLS-1$
-
- }catch(Exception e) {/* No tab will be created.*/}
-
- try
- {
- JEditorPane editorPane = new JEditorPane();
- editorPane.setEditable(false);
- editorPane.setDragEnabled(true);
-
- editorPane.setContentType("text/html");//$NON-NLS-1$
- editorPane.setBackground(tabbedPane.getBackground());
- editorPane.setText("<html><body><div style=\"text-align: center; \"><font size=\"-1\"><br>"+ //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.223")+"<br>"+//$NON-NLS-1$//$NON-NLS-2$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.224")+"<br><br>"+//$NON-NLS-1$//$NON-NLS-2$
- LaTeXDrawLang.getString1_6("LaTeXDrawFrame.18")+"<br>"+//$NON-NLS-1$//$NON-NLS-2$
- LaTeXDrawLang.getString1_6("LaTeXDrawFrame.19")+"<br><br>"+//$NON-NLS-1$//$NON-NLS-2$
- "The GPL library jlibeps is used to create EPS files."+"<br>"+//$NON-NLS-2$
- "<br></font></div></body></html>");//$NON-NLS-1$
-
- tabbedPane.add(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.25"), new JScrollPane(editorPane)); //$NON-NLS-1$
-
- }catch(Exception e) {/* No tab will be created.*/}
-
- try
- {
- JEditorPane editorPane = new JEditorPane(getClass().getResource("/res/translators.txt"));//$NON-NLS-1$
- editorPane.setEditable(false);
- editorPane.setDragEnabled(true);
- tabbedPane.add(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.26"), new JScrollPane(editorPane)); //$NON-NLS-1$
-
- }catch(Exception e) { /* No tab will be created.*/}
-
- try
- {
- JEditorPane editorPane = new JEditorPane(getClass().getResource("/release_note.txt"));//$NON-NLS-1$
- editorPane.setEditable(false);
- editorPane.setDragEnabled(true);
- tabbedPane.add(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.27"), new JScrollPane(editorPane)); //$NON-NLS-1$
-
- }catch(Exception e) {/* No tab will be created.*/}
-
- try
- {
- JEditorPane editorPane = new JEditorPane(getClass().getResource("/license.txt"));//$NON-NLS-1$
- editorPane.setEditable(false);
- editorPane.setDragEnabled(true);
- tabbedPane.add(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.28"), new JScrollPane(editorPane)); //$NON-NLS-1$
-
- }catch(Exception e) {/* No tab will be created.*/}
-
- tabbedPane.setPreferredSize(new Dimension(490, 290));
- p2.add(tabbedPane);
-
- aboutTeXDraw.setIconImage(Toolkit.getDefaultToolkit().getImage(
- getClass().getClassLoader().getResource("res/Inform.gif")));//$NON-NLS-1$
-
- okB.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- aboutTeXDraw.setVisible(false);
- }
- });
- panel.add(okB);
-
- aboutTeXDraw.getContentPane().setLayout(new BorderLayout());
- aboutTeXDraw.getContentPane().add(p2, BorderLayout.CENTER);
- aboutTeXDraw.getContentPane().add(panel, BorderLayout.SOUTH);
-
- aboutTeXDraw.setSize(500, 620);
- aboutTeXDraw.setResizable(false);
- }
-
-
-
- /**
- * A LaTeXDrawFrame must not be serialised
- * @param oos
- * @throws NotSerializableException
- */
- @SuppressWarnings("unused")
- private void writeObject(ObjectOutputStream oos) throws NotSerializableException
- {
- throw new NotSerializableException();
- }
-
-
-
- /**
- * A LaTeXDrawFrame must not be serialised
- * @throws NotSerializableException
- */
- private void readObject(@SuppressWarnings("unused") ObjectInputStream ois)
- throws NotSerializableException
- {
- throw new NotSerializableException();
- }
-
-
-
- /**
- * Actions to do when an item change.
- */
- public void itemStateChanged(ItemEvent e)
- {
- if(e.getSource() instanceof LaTeXDrawComboBox)
- {
- LaTeXDrawComboBox c = (LaTeXDrawComboBox)e.getSource();
- String label = c.getName();
-
- try
- {
- DrawContainer draw = drawPanel.getDraw();
- Draw listSelected = draw.getSelected();
-
- if(label.compareTo(Figure.LABEL_HATCH_CHOICE)==0)
- {
- String style = ((JLabel) hatchChoice.getSelectedItem()).getText();
- Object item = e.getItem();
-
- if(listSelected==null ||
- (item instanceof JLabel && ((JLabel)item).getName().compareTo(style)!=0 && listSelected.getNbFigures()<2))
- return ;
-
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- {
- Figure selected = listSelected.getFigureAt(0);
- selected.setHatchingStyle(style);
-
- if(style.compareTo(PSTricksConstants.TOKEN_FILL_GRADIENT)==0)
- {
- buttonGradientEndC.setVisible(true);
- buttonGradientStartC.setVisible(true);
- buttonInteriorColor.setVisible(false);
- filledCheckBox.setVisible(false);
- buttonHatchColor.setVisible(false);
- }
- else
- {
- buttonHatchColor.setVisible(style.compareTo(PSTricksConstants.TOKEN_FILL_SOLID)!=0 &&
- style.compareTo(PSTricksConstants.TOKEN_FILL_NONE)!=0);
- filledCheckBox.setVisible(true);
- buttonGradientEndC.setVisible(false);
- buttonGradientStartC.setVisible(false);
- buttonInteriorColor.setVisible(filledCheckBox.isSelected());
- }
- }
- else
- {
- genHatchS = style;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.canBeHatched())
- f.setHatchingStyle(style);
- }
-
- updateFillCB();
- drawPanel.updateDraw(true);
- setIsModified(true);
- return ;
- }
-
- if(label.compareTo(Figure.LABEL_BORDERS_POSITION_CHOICE)==0)
- {
- String style = ((JLabel) bordersPositionChoice.getSelectedItem()).getText();
- Object item = e.getItem();
-
- if(listSelected==null ||
- (item instanceof JLabel && ((JLabel)item).getName().compareTo(style)!=0 && listSelected.getNbFigures()<2))
- return ;
-
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- listSelected.getFigureAt(0).setBordersPosition(style);
- else
- {
- genBordPosS = style;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.isBordersMovable())
- f.setBordersPosition(style);
- }
-
- listSelected.updateBorders();
- drawPanel.updateDraw(true);
- setIsModified(true);
- return ;
- }
-
- if(label.compareTo(CHOICE_ARROW_LEFT_NAME)==0)
- {
- String arrowS = ((JLabel)lineArrowLChoice.getSelectedItem()).getText();
- Object item = e.getItem();
-
- if(listSelected==null ||
- (item instanceof JLabel && ((JLabel)item).getName().compareTo(arrowS)!=0 && listSelected.getNbFigures()<2))
- return ;
-
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- {
- Figure selected = listSelected.getFigureAt(0);
-
- if(selected instanceof Arrowable)
- ((Arrowable)selected).setArrow1Style(arrowS);
- }
- else
- {
- genLeftArrS = arrowS;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f instanceof Arrowable)
- ((Arrowable)f).setArrow1Style(arrowS);
- }
-
- drawPanel.updateDraw(true);
- setIsModified(true);
- return;
- }
-
- if(label.compareTo(CHOICE_ARROW_RIGHT_NAME)==0)
- {
- String arrowS = ((JLabel)lineArrowRChoice.getSelectedItem()).getText();
- Object item = e.getItem();
-
- if(listSelected==null ||
- (item instanceof JLabel && ((JLabel)item).getName().compareTo(arrowS)!=0 && listSelected.getNbFigures()<2))
- return ;
-
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- {
- Figure selected = listSelected.getFigureAt(0);
-
- if(selected instanceof Arrowable)
- {
- if(((Arrowable)selected).hasTwoLeftArrows())
- arrowS = ArrowHead.invertArrowStyle(arrowS);
-
- ((Arrowable)selected).setArrow2Style(arrowS);
- }
- }
- else
- {
- genRightArrS = arrowS;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f instanceof Arrowable)
- ((Arrowable)f).setArrow2Style(((Arrowable)f).hasTwoLeftArrows() ?
- ArrowHead.invertArrowStyle(arrowS) : arrowS);
- }
-
- drawPanel.updateDraw(true);
- setIsModified(true);
- return;
- }
-
-
- if(label.compareTo(CHOICE_LINE_NAME)==0)
- {
- String str = ((JLabel) lineChoice.getSelectedItem()).getText();
- Object item = e.getItem();
-
- if(listSelected==null ||
- (item instanceof JLabel && ((JLabel)item).getName().compareTo(str)!=0 && listSelected.getNbFigures()<2))
- return ;
-
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- listSelected.getFigureAt(0).setLineStyle(str);
- else
- {
- genLineStyleS = str;
-
- for(Figure f : listSelected.getFigures())
- if(f.isCustomizable() && f.isDashableOrDotable())
- f.setLineStyle(str);
- }
-
- drawPanel.updateDraw(true);
- setIsModified(true);
- return ;
- }
-
-
- if(label.compareTo(CHOICE_DOT_NAME)==0)
- {
- String str = ((JLabel) dotChoice.getSelectedItem()).getText();
- Object item = e.getItem();
-
- if(listSelected==null ||
- (item instanceof JLabel && ((JLabel)item).getName().compareTo(str)!=0 && listSelected.getNbFigures()<2))
- return ;
-
- if(listSelected.getNbFigures()>0)
- addToUndoTransformation(listSelected);
-
- if(listSelected.getNbFigures()==1)
- {
- Figure selected = listSelected.getFigureAt(0);
-
- if(selected instanceof Dot)
- {
- ((Dot)selected).setCurrentStyle(str);
- filledCheckBox.setVisible(false);
- buttonInteriorColor.setVisible(((Dot)selected).canBeFilled() && selected.isFilled());
- }
- }
- else
- {
- genDotS = str;
-
- for(Figure f : listSelected.getFigures())
- if(f instanceof Dot)
- ((Dot)f).setCurrentStyle(str);
- }
-
- drawPanel.updateDraw(true);
- return;
- }
-
- }catch(Exception ex)
- {
- ex.printStackTrace();
- ExceptionFrameDialog.showExceptionDialog(ex);
- }
- }
- }
-
-
- /**
- * @return Returns the reloadIcon.
- */
- public static ImageIcon getReloadIcon()
- {
- return reloadIcon;
- }
-
-
-
-
- /**
- * @return Returns the xScale.
- */
- public synchronized XScale getXScale()
- {
- return xScale;
- }
-
-
-
-
- /**
- * @return Returns the yScale.
- */
- public synchronized YScale getYScale()
- {
- return yScale;
- }
-
-
-
-
-
-
- /**
- * @return the checkNewVersion
- */
- public synchronized boolean isCheckNewVersion()
- {
- return checkNewVersion;
- }
-
-
-
-
-
-
- /**
- * @param checkNewVersion the checkNewVersion to set
- */
- public synchronized void setCheckNewVersion(boolean checkNewVersion)
- {
- this.checkNewVersion = checkNewVersion;
- }
-
-
-
-
-
-
- /**
- * @return the text of statusBar
- */
- public synchronized String getStatusBarText()
- {
- return statusBar.getText();
- }
-
-
-
-
-
- /**
- * @param text The text to put in the statusbar
- */
- public synchronized void setStatusBarText(String text)
- {
- statusBar.setText(text);
- }
-
-
-
-
- /**
- * @param unitForPixelsPerCm The unitForPixelsPerCm to set.
- */
- public void setUnitForPixelsPerCm(String unitForPixelsPerCm)
- {
- drawPanel.getDraw().setUnitForPixelsPerCm(unitForPixelsPerCm);
- xScale.setUnitForPixelsPerCm(unitForPixelsPerCm);
- }
-
-
-
-
- /**
- * Allows to choose and to insert a picture in the draw
- */
- public void insertPicture()
- {
- try
- {
- if(fileChooserPicture==null)
- fileChooserPicture = new PictureChooser(this, LaTeXDrawLang.getString1_6("LaTeXDrawFrame.23") //$NON-NLS-1$
- ,true, LaTeXDrawLang.getString1_6("LaTeXDrawFrame.24")); //$NON-NLS-1$
-
- File file = fileChooserPicture.displayFrame();
-
- if(file==null || !file.canRead() || !file.isFile())
- return ;
-
- setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.25")); //$NON-NLS-1$
-
- if(convertFrame==null)
- convertFrame = new BatchConvertFrame();
-
- Image image = convertFrame.getImage(file);
-
- if(image==null || image.getWidth(null)<1 || image.getHeight(null)<1)
- {
- JOptionPane.showMessageDialog(this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.204") + //$NON-NLS-1$
- LaTeXDrawLang.getString1_6("LaTeXDrawFrame.26"), //$NON-NLS-1$
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.194"), //$NON-NLS-1$
- JOptionPane.WARNING_MESSAGE
- );
- setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.27")); //$NON-NLS-1$
- }
- else
- {
- boolean state = drawPanel.insertPicture(image, undoManager, file.getAbsolutePath());
-
- if(state) setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.28")); //$NON-NLS-1$
- else setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.29")); //$NON-NLS-1$
- }
-
- }catch(Exception ex)
- {
- ex.printStackTrace();
- JOptionPane.showMessageDialog(
- this,
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.204") + //$NON-NLS-1$
- ex.toString(),
- LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.194"), //$NON-NLS-1$
- JOptionPane.WARNING_MESSAGE
- );
- }
- }
-
-
-
-
- /**
- * Allows to convert several figures in an other format.
- */
- public void batchConvertion()
- {
- if(convertFrame==null)
- convertFrame = new BatchConvertFrame();
-
- convertFrame.setVisible(true);
- }
-
-
-
-
-
-
- /**
- * Actions to do during the parsing of a PSTricks file.
- */
- public void run()
- {
- LaTeXDrawPSTricksParserActions ltpa = new LaTeXDrawPSTricksParserActions();
- texParser = new PSTricksParser(ltpa);
- progressBar.setValue(0);
- stopButton.setVisible(true);
- progressBar.setVisible(true);
-
- int res;
-
- if(fileToParse!=null)
- res = texParser.parse(fileToParse, this, progressBar);
- else res = texParser.parse(codeToParse, this, progressBar);
-
- Vector<Figure> fig = ltpa.getFigures();
-
- switch(res)
- {
- case PSTricksParser.ERROR_PARSING :
-
- setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.34")); //$NON-NLS-1$
- break;
-
- case PSTricksParser.CANCEL_PARSING :
-
- setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.35")); //$NON-NLS-1$
- break;
-
- case PSTricksParser.OK_PARSING :
-
- if(fig==null || fig.isEmpty())
- {
- JOptionPane.showMessageDialog( this,
- LaTeXDrawLang.getString1_6("LaTeXDrawFrame.30") //$NON-NLS-1$
- +MAIL_ME+ LaTeXDrawLang.getString1_6("LaTeXDrawFrame.31"), LaTeXDrawLang.getString1_6("LaTeXDrawFrame.32"), //$NON-NLS-1$ //$NON-NLS-2$
- JOptionPane.WARNING_MESSAGE );
- setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.33")); //$NON-NLS-1$
- }
- else
- {
- LaTeXDrawPSTricksParserActions.optimizeCode(fig);
- DrawContainer draw = drawPanel.getDraw();
-
- for(Figure f : fig)
- draw.addFigure(f, undoManager);
-
- draw.recenterFigures();
- codePanel.setPositionHoriToken(PSTricksParameters.isCentered ?
- CodePanel.TOKEN_HORI_CENTER_START : CodePanel.TOKEN_HORI_VERT_DEFAULT);
- codePanel.setPositionVertToken(PSTricksParameters.tokenPosition);
- drawPanel.updateDraw(true);
- setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.36")); //$NON-NLS-1$
- exportAsMenu.setEnabled(true);
- drawPanel.setIsModified(true);
- }
- break;
- }
-
- parsingThread=null;
- progressBar.setVisible(false);
- stopButton.setVisible(false);
- fileToParse = null;
- codeToParse = null;
- }
-
-
-
-
-
- /**
- * @param state Define if the grid must be magnetic.
- */
- public void setMagneticGrid(boolean state)
- {
- magneticCB.setSelected(state);
- drawPanel.setGridIsMagnetic(state);
- }
-
-
-
-
- /**
- * @param value Define the interval between two lines of the personal grid.
- */
- public void setPersoGridGap(int value)
- {
- persoGridGapField.setValue(value);
- drawPanel.draw.setPersonalGridGap(value);
- }
-
-
-
-
-
-
- /**
- * @return the pathTexEditor.
- */
- public synchronized String getPathTexEditor()
- {
- return pathTexEditor;
- }
-
-
-
-
-
-
- /**
- * @param pathTexEditor the pathTexEditor to set.
- */
- public synchronized void setPathTexEditor(String pathTexEditor)
- {
- this.pathTexEditor = pathTexEditor;
- }
-
-
-
- /**
- * Select all the figures of the current drawing and put the current action to "selection".
- * @since 1.9
- */
- public void selectAllFigures()
- {
- menuSelect.setSelected(true);
- buttonImageSelect.setSelected(true);
- actionPerformed(new ActionEvent(menuSelect, 0, LABEL_SELECT_FIGURE));
- drawPanel.getDraw().selectAll();
- setSelection(true);
- setCurrentChoice(LABEL_SELECT_FIGURE);
- }
-
-
-
-
- public void showShortcutsFrame()
- {
- if(shortcutsFrame==null)
- shortcutsFrame = new ShortcutsFrame();
-
- shortcutsFrame.setVisible(true);
- }
-
-
-
-
- public static synchronized void setCurrentChoice(String currentChoice)
- {
- LaTeXDrawFrame.currentChoice = currentChoice;
- }
-
-
-
-
- public synchronized void setFormerIsInAutoUpdate(boolean formerIsInAutoUpdate)
- {
- this.formerIsInAutoUpdate = formerIsInAutoUpdate;
- }
-
-
-
-
- /**
- * @return the lookAndFeel.
- * @since 1.9
- */
- public synchronized String getLookAndFeel()
- {
- return lookAndFeel;
- }
-
-
-
-
- /**
- * @param lookAndFeel the lookAndFeel to set.
- * @since 1.9
- */
- public synchronized void setLookAndFeel(String lookAndFeel)
- {
- this.lookAndFeel = lookAndFeel;
- }
-
-
- /**
- * @return True if the selection of figures is activated.
- * @since 1.9
- */
- public synchronized boolean isOnSelection()
- {
- return menuSelect.isSelected();
- }
-
-
-
- /** @return the curvesFreehandIcon. */
- public static synchronized ImageIcon getCurvesFreehandIcon() { return curvesFreehandIcon; }
-
- /** @return the linesFreehandIcon. */
- public static synchronized ImageIcon getLinesFreehandIcon() { return linesFreehandIcon; }
-
- /** @return the closeLineIcon. */
- public static synchronized ImageIcon getCloseLineIcon() { return closeLineIcon; }
-
- /** @return the closeCurveIcon. */
- public static synchronized ImageIcon getCloseCurveIcon() { return closeCurveIcon; }
-
-
-
- /**
- * Define if the CheckBox FillCB must be enable or not considering if the current selected figure.
- * has a shadow or not (in pstricks, all shape having a shadow is filled but joined-lines, akin-points and Bézier curves).
- * @since 1.9
- */
- protected void updateFillCB()
- {
- Draw selection = drawPanel.draw.getSelected();
-
- if(selection!=null && selection.getNbFigures()==1)
- {
- Figure f = selection.getFigureAt(0);
-
- if(!f.canBeFilled())
- return ;
-
- if(f instanceof JoinedLines || f instanceof BezierCurve || f instanceof AkinPoints)
- {
- String txt = f.getHatchingStyle();
-
- filledCheckBox.setEnabled(!(shadowCheckBox.isSelected() && f.canHaveShadow() &&
- (txt.compareTo(PSTricksConstants.TOKEN_FILL_CROSSHATCH)==0 ||
- txt.compareTo(PSTricksConstants.TOKEN_FILL_CROSSHATCH_F)==0 ||
- txt.compareTo(PSTricksConstants.TOKEN_FILL_HLINES)==0 ||
- txt.compareTo(PSTricksConstants.TOKEN_FILL_HLINES_F)==0 ||
- txt.compareTo(PSTricksConstants.TOKEN_FILL_VLINES)==0 ||
- txt.compareTo(PSTricksConstants.TOKEN_FILL_VLINES_F)==0)));
- }
- else
- filledCheckBox.setEnabled(!shadowCheckBox.isSelected() || !f.canHaveShadow());
- }
- }
-
-
-
-
- /**
- * Initialise the values of the general parameters (do not change the fields).
- * @since 1.9.1
- */
- protected void initializeGeneralFields()
- {
- genBordPosS = Figure.DEFAULT_BORDERS_POSITION;
- genDbleBordCB.setColor(Figure.DEFAULT_DOUBLE_COLOR);
- genDotS = Dot.DEFAULT_DOT_STYLE;
- genGradientEndCB.setColor(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR);
- genGradientStartCB.setColor(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR);
- genHasDbleBord = Figure.DEFAULT_HAS_DOUBLE_BOUNDARY;
- genHatchCB.setColor(Figure.DEFAULT_HATCH_COL);
- genHatchS = Figure.DEFAULT_HATCH_STYLE;
- genInteriorCB.setColor(Figure.DEFAULT_INTERIOR_COL);
- genIsFilled = Figure.DEFAULT_IS_FILLED;
- genLeftArrS = genRightArrS = ArrowHead.DEFAULT_STYLE;
- genLineCB.setColor(Figure.DEFAULT_BORDERS_COL);
- genLineStyleS = Figure.DEFAULT_LINE_STYLE;
- genThickness = Figure.DEFAULT_THICKNESS;
- genDotSize = Dot.DEFAULT_WIDTH;
- genGradientEndC = PSTricksConstants.DEFAULT_GRADIENT_END_COLOR;
- genGradientStartC = PSTricksConstants.DEFAULT_GRADIENT_START_COLOR;
- genDbleC = Figure.DEFAULT_DOUBLE_COLOR;
- genHatchC = Figure.DEFAULT_HATCH_COL;
- genInteriorC = Figure.DEFAULT_INTERIOR_COL;
- genLineC = Figure.DEFAULT_BORDERS_COL;
- genShadowC = Figure.DEFAULT_SHADOW_COLOR;
- }
-
-
- /**
- * @return The path of the profile of latexdraw of the current user.
- * @since 1.9.2
- */
- public static String getPathLocalUser()
- {
- String os = System.getProperty("os.name").toLowerCase();//$NON-NLS-1$
- String home = System.getProperty("user.home");//$NON-NLS-1$
-
- if(os.compareTo("windows vista")==0)//$NON-NLS-1$
- return home + "\\AppData\\Local\\latexdraw";//$NON-NLS-1$
-
- if(os.compareTo("Mac OS X")==0)//$NON-NLS-1$
- return home + "/Library/Preferences/latexdraw";//$NON-NLS-1$
-
- return home + "/.latexdraw";//$NON-NLS-1$
- }
-
-
- /**
- * @return The path of the shared templates (depends of the OS).
- * @since 1.9.2
- */
- public static String getPathTemplatesShared()
- {
- if(System.getProperty("os.name").toLowerCase().compareTo("linux")==0)//$NON-NLS-1$//$NON-NLS-2$
- return "/usr/share/latexdraw/templates";//$NON-NLS-1$
-
- return null;
- }
-
-}
-
-
+package latexDraw.ui;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.PrinterJob;
+import java.io.*;
+import java.net.URL;
+import java.util.Vector;
+
+import javax.print.*;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+
+import latexDraw.figures.*;
+import latexDraw.figures.properties.Arrowable;
+import latexDraw.filters.*;
+import latexDraw.generators.svg.SVGDocumentGenerator;
+import latexDraw.lang.LaTeXDrawLang;
+import latexDraw.parsers.pstricks.PSTricksParser;
+import latexDraw.psTricks.PSTricksConstants;
+import latexDraw.ui.components.*;
+import latexDraw.ui.components.progressbars.PSTProgressBarManager;
+import latexDraw.ui.components.progressbars.SVGProgressBarManager;
+import latexDraw.ui.dialog.*;
+import latexDraw.ui.listeners.MenusListener;
+import latexDraw.ui.listeners.RecentFilesListener;
+import latexDraw.ui.listeners.ShortcutsListener;
+import latexDraw.ui.listeners.ToolbarListener;
+import latexDraw.util.*;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * This class contains all the elements of the graphic interface.<br>
+ * <br>
+ * This file is part of LaTeXDraw<br>
+ * Copyright (c) 2005-2008 Arnaud BLOUIN<br>
+ * <br>
+ * LaTeXDraw 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.<br>
+ * <br>
+ * LaTeXDraw is distributed 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.<br>
+ * <br>
+ * 04/05/06<br>
+ * @author Arnaud BLOUIN<br>
+ * @version 2.0.0<br>
+ */
+public final class LaTeXDrawFrame extends JFrame implements ActionListener, ItemListener, ChangeListener, WindowStateListener
+{
+ private static final long serialVersionUID = 1L;
+
+ /** The version of the application */
+ public final static String VERSION = "2.0.0";//$NON-NLS-1$
+
+ public final static String VERSION_STABILITY = ""; //$NON-NLS-1$
+
+ /** To change if update is needed or not. */
+ public static final boolean WITH_UPDATE = true;
+
+ public static final Insets INSET_BUTTON = new Insets(1,1,1,1);
+
+ /** The path by default */
+ public static final String DEFAULT_PATH = System.getProperty("user.home");//$NON-NLS-1$
+
+ protected ShortcutsFrame shortcutsFrame;
+
+ protected PSTProgressBarManager progressbarPST = null;
+
+ protected SVGProgressBarManager progressbarSVG = null;
+
+ protected transient MenusListener menusListener;
+
+ protected transient RecentFilesListener recentFilesListener;
+
+ /** The path of the location of the LaTeX editor. */
+ private String pathTexEditor = null;
+
+ /** This frame allows the user to insert PSTricks code in the drawing. */
+ private InsertPSTricksCodeFrame insertCodeFrame;
+
+ /** The panel containing the generated code*/
+ protected CodePanel codePanel;
+
+ /** The panel containing the drawing made by the user*/
+ protected DrawPanel drawPanel;
+
+ /** The toolbar of the application*/
+ protected LToolbar toolbar;
+
+ /** The progress bar for the parsing */
+ protected JProgressBar progressBar;
+
+ /** The button stop for the parsing */
+ protected JButton stopButton;
+
+ /** The menu bar of the application */
+ protected LMenuBar menuBar;
+
+ /** The identifier of the build */
+ private static final String ID_BUILD = "20080724";//$NON-NLS-1$
+
+ /** Allows to realize undo and redo */
+ protected transient UndoRedoManager undoManager;
+
+ /** This frame allows to set the parameters of a line */
+ private ParametersLineFrame paramLineFrame;
+
+ /** This frame allows to set the parameters of axes. */
+ private ParametersAxeFrame paramAxesFrame;
+
+ /** This frame allows to set the parameters of a circle */
+ private ParametersCircleSquareFrame paramCircleFrame;
+
+ /** This frame allows to set the parameters of an ellipse */
+ private ParametersEllipseRectangleFrame paramEllipseFrame;
+
+ /** This frame allows to set the parameters of a Bézier curve */
+ private ParametersBezierCurveFrame paramBezierCurveFrame;
+
+ /** This frame allows to set the parameters of akin points */
+ private ParametersAkinPointsFrame paramAkinPointsFrame;
+
+ /** This frame allows to set the parameters of a dot */
+ private ParametersDotFrame paramDotFrame;
+
+ /** This frame allows to set the parameters of a text */
+ private ParametersTextFrame paramTextFrame;
+
+ /** This frame allows to set the parameters of a triangle */
+ private ParametersTriangleFrame paramTriangleFrame;
+
+// /** This frame allows to set the parameters of a drawing */
+// private ParametersDrawFrame paramDrawFrame;
+
+ /** This frame allows to set the parameters of a grid */
+ private ParametersGridFrame paramGridFrame;
+
+ /** This frame allows to set the parameters of a rhombus */
+ private ParametersRhombusFrame paramRhombusFrame;
+
+ /** This frame allows to set the parameters of an arc */
+ private ParametersArcFrame paramArcFrame;
+
+ /** This frame allows to set the parameters of a polygon */
+ private ParametersPolygonJoinedLinesFrame paramPolygonFrame;
+
+ /** This frame allows to set the parameters of several joined lines */
+ private ParametersPolygonJoinedLinesFrame paramJoinedLinesFrame;
+
+ /** This frame allows the user to add comments to his drawing */
+ private AddCommentsFrame addCommentsFrame;
+
+ /** This frame allows to set the parameters of the drawing (not the
+ * Figure.Draw */
+ private DrawPropertiesFrame drawPropertiesFrame;
+
+ /** Allows to display a frame displaying the LaTeXDraw help */
+ private JFrame helpFrame;
+
+ /** The current file of the project */
+ private File currentFile;
+
+ /** The path used on open/save actions */
+ private static String pathOpen = DEFAULT_PATH;
+
+ /** The path used on exportation actions */
+ private static String pathExport = DEFAULT_PATH;
+
+ /** The frame which allows to convert pictures */
+ public final static BatchConvertFrame convertFrame;
+
+ /** Allows to know if the program must check new version */
+ private boolean checkNewVersion;
+
+ /** The About LaTeXDraw box */
+ protected JFrame aboutTeXDraw;
+
+ /** This frame allows the user to set his preferences */
+ private PreferencesFrame preferencesFrame;
+
+ /** Correspond to the current choice of the user (draw a line, ...). */
+ private static String currentChoice;
+
+ /** Corresponds to the name of the current project */
+ private String projectName;
+
+ /** The fileChooser used to save projects. */
+ private JFileChooser fileChooserSave;
+
+ /** The fileChooser used to open projects. @since 2.0.0 */
+ private JFileChooser fileChooserOpen;
+
+ /** The PictureChooser for 'insert picture' actions */
+ private PictureChooser fileChooserPicture;
+
+ /** The fileChooser for save/open actions */
+ private ExportDialog fileChooserExport;
+
+ /** The PictureChooser for import actions */
+ private PictureChooser fileChooserImport;
+
+ /** Allows to know if by default the grid must be displayed */
+ public static final boolean DEFAULT_DISPLAY_GRID = true;
+
+ /** Allows to know if by default the XScale must be displayed */
+ public static final boolean DEFAULT_DISPLAY_XSCALE = true;
+
+ /** Allows to know if by default the YScaleC must be displayed */
+ public static final boolean DEFAULT_DISPLAY_YSCALE = true;
+
+ /** Allows to know if by default the codePane must be displayed */
+ public static final boolean DEFAULT_DISPLAY_CODEPANEL = true;
+
+ /** Allows to know if by default the borders of the drawing must be displayed */
+ public static final boolean DEFAULT_DISPLAY_BORDERS = false;
+
+ /** Allows to know if by default the program must check new version on start-up */
+ public static final boolean DEFAULT_CHECK_VERSION = true;
+
+ /** The splitpane of the program */
+ protected JSplitPane splitPane;
+
+ /** The field which allows to change the thickness of figures */
+ private JSpinner thicknessField;
+
+ /** Allows to set the colour of the borders of a figure */
+ private ColorButton buttonBordersColor;
+
+ /** Allows the attribute "filled" in Figure class */
+ private JCheckBox filledCheckBox;
+
+ /** Set/unset a shadow to a figure. */
+ private JCheckBox shadowCheckBox;
+
+ /** Allows have double boundaries on a figure */
+ private JCheckBox dbleBoundCheckBox;
+
+ /** Allows to set the colour of the interior of a figure */
+ private ColorButton buttonInteriorColor;
+
+ /** Allows to set the colour of the shadow of a figure */
+ private ColorButton buttonShadowColor;
+
+ /** Allows to change the colour of the hatch */
+ private ColorButton buttonHatchColor;
+
+ /** Contains buttons allowing to rotate figures. */
+ private ListJToggleButton rotationButtons;
+
+ /** Contains the buttons allowing to return figures (mirrors). */
+ private ListJToggleButton mirrorButtons;
+
+ private ListJToggleButton alignButtons;
+
+ private ListJToggleButton distribButtons;
+
+ /** Allows to select the type of the dot */
+ private LaTeXDrawComboBox dotChoice;
+
+ /** Allows to select the position of the borders of the figure (if possible) */
+ private LaTeXDrawComboBox bordersPositionChoice;
+
+ /** Allows to change the colour of the space between the double boundaries */
+ private ColorButton buttonDbleBoundColor;
+
+ /** This button allows to join several figures */
+ private JButton joinButton;
+
+ /** This button allows to separate several figures */
+ private JButton separateButton;
+
+ /** Allows to change the style of the left-end of the line */
+ private LaTeXDrawComboBox lineArrowLChoice;
+
+ /** Allows to change the style of the right-end of the line */
+ private LaTeXDrawComboBox lineArrowRChoice;
+
+ /** Allows to change the style of the line */
+ private LaTeXDrawComboBox lineChoice;
+
+ /** Allows to change the style of hatch */
+ private LaTeXDrawComboBox hatchChoice;
+
+ /** Allows to choose the first colour of a gradient. */
+ private ColorButton buttonGradientStartC;
+
+ /** Allows to choose the second colour of a gradient. */
+ private ColorButton buttonGradientEndC;
+
+ /** The former location of the divider location (used to show or hide the codepanel) */
+ private int formerDividerLocation;
+
+ private ListJToggleButton locationButtons;
+
+ /** The version of the LaTeXDraw file loaded */
+ private static String versionOfFile = "";//$NON-NLS-1$
+
+ /** The X-scale of the drawing */
+ private XScale xScale;
+
+ /** The Y-scale of the drawing */
+ private YScale yScale;
+
+ /** This label is behind the field thickness in the paramsToolbar */
+ private JLabel labelThickness;
+
+ /** The older version of java that this program can used */
+ public static final String VERSION_MIN = "1.5"; //$NON-NLS-1$
+
+ /** This attribute is used to save the value of the "updateCode" checkBox
+ * of the code panel when we hide to code panel (we disactivate the auto-update when to code panel is hidden */
+ private boolean formerIsInAutoUpdate;
+
+ /** The status-bar of the frame */
+ private JTextField statusBar;
+
+ /** The look and feel of the program. */
+ private static String lookAndFeel;
+
+ protected transient ShortcutsListener shortcutsListener;
+
+ protected JToggleButton rotateButton;
+
+ /* Save of the general parameters. */
+ protected ColorButton genGradientEndCB;
+ protected ColorButton genGradientStartCB;
+ protected ColorButton genLineCB;
+ protected ColorButton genInteriorCB;
+ protected ColorButton genDbleBordCB;
+ protected ColorButton genHatchCB;
+ protected ColorButton genShadowCB;
+ protected Color genGradientEndC;
+ protected Color genGradientStartC;
+ protected Color genLineC;
+ protected Color genInteriorC;
+ protected Color genDbleC;
+ protected Color genHatchC;
+ protected Color genShadowC;
+ protected float genThickness;
+ protected float genDotSize;
+ protected boolean genIsFilled;
+ protected boolean genHasDbleBord;
+ protected boolean genHasShadow;
+ protected String genHatchS;
+ protected String genDotS;
+ protected String genLineStyleS;
+ protected String genLeftArrS;
+ protected String genRightArrS;
+ protected String genBordPosS;
+ protected ListJToggleButton genColorL;
+
+ protected JSpinner dotSizeField;
+ protected JLabel labelDotSize;
+
+ /** The position of the divider in ]0,1[. @since 2.0.0 */
+ protected double dividerPosition;
+
+
+ static
+ {
+ LaTeXDrawPath.checkDirectories();
+
+ try
+ {
+ lookAndFeel = PreferencesFrame.readTheme();
+ UIManager.setLookAndFeel(lookAndFeel);
+ }
+ catch(Exception ex) { /* Dommage ! */ }
+
+ convertFrame = new BatchConvertFrame();
+ }
+
+
+
+ /** The constructor by default. */
+ public LaTeXDrawFrame(String[] args, boolean splash)
+ {
+ dividerPosition = 0.8;
+
+ SplashScreen splashScreen = new SplashScreen(lookAndFeel);
+
+ if(splash)
+ splashScreen.setVisible(true);
+
+ try
+ {
+ splashScreen.addToProgressBar(5);
+ statusBar = new JTextField("");//$NON-NLS-1$
+ statusBar.setEditable(false);
+
+ progressBar = new JProgressBar();
+ progressBar.setMaximumSize(new Dimension(300, 20));
+ progressBar.setPreferredSize(new Dimension(300, 20));
+ progressBar.setVisible(false);
+
+ menusListener = new MenusListener(this);
+
+ splashScreen.addToProgressBar(15);
+ setIconImage(LaTeXDrawResources.latexdrawIcon.getImage());
+
+ checkNewVersion = DEFAULT_CHECK_VERSION && WITH_UPDATE;
+ codePanel = new CodePanel(this);
+ codePanel.setVisible(DEFAULT_DISPLAY_CODEPANEL);
+ splashScreen.addToProgressBar(5);
+ DrawContainer draw = new DrawContainer(DEFAULT_DISPLAY_BORDERS);
+ splashScreen.addToProgressBar(10);
+ drawPanel = new DrawPanel(draw, codePanel, this);
+ splashScreen.addToProgressBar(5);
+
+ JPanel paramsToolbar = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ JPanel p= new JPanel();
+
+ projectName = null;
+ fileChooserSave = null;
+ fileChooserExport = null;
+ currentFile = null;
+
+ splashScreen.addToProgressBar(5);
+ menuBar = new LMenuBar(this);
+ splashScreen.addToProgressBar(10);
+ createToolbar();
+ splashScreen.addToProgressBar(10);
+
+ undoManager = new UndoRedoManager(draw.getFigures(), draw, this);
+ splashScreen.addToProgressBar(5);
+
+ yScale = new YScale(drawPanel, xScale);
+ yScale.setVisible(DEFAULT_DISPLAY_YSCALE);
+ xScale = new XScale(drawPanel, yScale);
+ yScale.setXScale(xScale);
+ xScale.setVisible(DEFAULT_DISPLAY_XSCALE);
+
+ p.setLayout(new BorderLayout());
+ p.add(yScale, BorderLayout.WEST);
+ p.add(xScale, BorderLayout.NORTH);
+ p.add(drawPanel, BorderLayout.CENTER);
+ setJMenuBar(menuBar);
+ updateUndoRedo();
+ splashScreen.addToProgressBar(10);
+
+ splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, p, codePanel);
+ splitPane.setContinuousLayout(true);
+ splitPane.setOneTouchExpandable(true);
+ splitPane.setDividerSize(6);
+
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().add(toolbar, BorderLayout.NORTH);
+ getContentPane().add(splitPane, BorderLayout.CENTER);
+
+ addCommentsFrame = new AddCommentsFrame(this);
+
+ SpinnerModel model = new SpinnerNumberModel(Figure.DEFAULT_THICKNESS,0.1,1000,0.1);
+ thicknessField = new JSpinner(model);
+ thicknessField.setEditor(new JSpinner.NumberEditor(thicknessField, "0.0"));//$NON-NLS-1$
+ thicknessField.addChangeListener(this);
+ thicknessField.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.65")); //$NON-NLS-1$
+ thicknessField.setName(LaTeXDrawResources.NAME_THICKNESS_FIELD);
+ thicknessField.setMaximumSize(new Dimension(55, 30));
+ thicknessField.setMinimumSize(new Dimension(55, 30));
+ thicknessField.setPreferredSize(new Dimension(55, 30));
+
+ model = new SpinnerNumberModel(Dot.DEFAULT_WIDTH,0.1,1000,0.1);
+ dotSizeField = new JSpinner(model);
+ dotSizeField.setEditor(new JSpinner.NumberEditor(dotSizeField, "0.0"));//$NON-NLS-1$
+ dotSizeField.addChangeListener(this);
+ dotSizeField.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.0")); //$NON-NLS-1$
+ dotSizeField.setName(LaTeXDrawResources.NAME_DOT_SIZE_FIELD);
+ dotSizeField.setMaximumSize(new Dimension(55, 30));
+ dotSizeField.setMinimumSize(new Dimension(55, 30));
+ dotSizeField.setPreferredSize(new Dimension(55, 30));
+ labelDotSize = new JLabel(LaTeXDrawResources.dotStyleNoneIcon);
+
+ buttonBordersColor = new ColorButton(LaTeXDrawResources.LABEL_COLOR_BUTTON, new ButtonIcon(Color.BLACK));
+ buttonBordersColor.setMargin(INSET_BUTTON);
+ buttonBordersColor.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.66")); //$NON-NLS-1$
+ buttonBordersColor.setActionCommand(LaTeXDrawResources.LABEL_COLOR_BUTTON);
+ buttonBordersColor.addActionListener(this);
+ genLineCB = new ColorButton(LaTeXDrawResources.LABEL_COLOR_BUTTON, new ButtonIcon(Color.BLACK));
+ genLineCB.setMargin(INSET_BUTTON);
+ genLineCB.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.66")); //$NON-NLS-1$
+ genLineCB.setActionCommand(LaTeXDrawResources.LABEL_COLOR_BUTTON);
+ genLineCB.addActionListener(this);
+
+ filledCheckBox = new JCheckBox(LaTeXDrawResources.LABEL_FILLED_CHECKBOX);
+ filledCheckBox.setMargin(LaTeXDrawFrame.INSET_BUTTON);
+ filledCheckBox.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.67")); //$NON-NLS-1$
+ filledCheckBox.setActionCommand(LaTeXDrawResources.LABEL_FILLED_CHECKBOX);
+ filledCheckBox.addActionListener(this);
+
+ buttonInteriorColor = new ColorButton(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON, new ButtonIcon(Figure.DEFAULT_INTERIOR_COL));
+ buttonInteriorColor.setMargin(INSET_BUTTON);
+ buttonInteriorColor.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.68")); //$NON-NLS-1$
+ buttonInteriorColor.setActionCommand(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON);
+ buttonInteriorColor.addActionListener(this);
+ genInteriorCB = new ColorButton(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON, new ButtonIcon(Figure.DEFAULT_INTERIOR_COL));
+ genInteriorCB.setMargin(INSET_BUTTON);
+ genInteriorCB.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.68")); //$NON-NLS-1$
+ genInteriorCB.setActionCommand(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON);
+ genInteriorCB.addActionListener(this);
+
+ buttonHatchColor = new ColorButton(LaTeXDrawResources.LABEL_COLOR_HATCH, new ButtonIcon(Figure.DEFAULT_BORDERS_COL));
+ buttonHatchColor.setMargin(INSET_BUTTON);
+ buttonHatchColor.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.69")); //$NON-NLS-1$
+ buttonHatchColor.setActionCommand(LaTeXDrawResources.LABEL_COLOR_HATCH);
+ buttonHatchColor.addActionListener(this);
+ genHatchCB = new ColorButton(LaTeXDrawResources.LABEL_COLOR_HATCH, new ButtonIcon(Figure.DEFAULT_BORDERS_COL));
+ genHatchCB.setMargin(INSET_BUTTON);
+ genHatchCB.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.69")); //$NON-NLS-1$
+ genHatchCB.setActionCommand(LaTeXDrawResources.LABEL_COLOR_HATCH);
+ genHatchCB.addActionListener(this);
+
+ dotChoice = Dot.createDotStyleChoice();
+ dotChoice.setName(LaTeXDrawResources.CHOICE_DOT_NAME);
+ dotChoice.addItemListener(this);
+ dotChoice.setPreferredSize(new Dimension(55,30));
+ dotChoice.setMaximumSize(new Dimension(55,30));
+
+ lineChoice = Figure.createStyleLineChoice();
+ lineChoice.setName(LaTeXDrawResources.CHOICE_LINE_NAME);
+ lineChoice.addItemListener(this);
+ lineChoice.setPreferredSize(new Dimension(70,30));
+ lineChoice.setMaximumSize(new Dimension(70,30));
+
+ hatchChoice = Figure.createFillChoice();
+ hatchChoice.addItemListener(this);
+ hatchChoice.setPreferredSize(new Dimension(65,30));
+ hatchChoice.setMaximumSize(new Dimension(65,30));
+
+ lineArrowLChoice = ArrowHead.createLeftArrowStyleList();
+ lineArrowLChoice.setName(LaTeXDrawResources.CHOICE_ARROW_LEFT_NAME);
+ lineArrowLChoice.addItemListener(this);
+ lineArrowLChoice.setPreferredSize(new Dimension(80,30));
+ lineArrowLChoice.setMaximumSize(new Dimension(80,30));
+
+ lineArrowRChoice = ArrowHead.createRightArrowStyleList();
+ lineArrowRChoice.setName(LaTeXDrawResources.CHOICE_ARROW_RIGHT_NAME);
+ lineArrowRChoice.addItemListener(this);
+ lineArrowRChoice.setPreferredSize(new Dimension(80,30));
+ lineArrowRChoice.setMaximumSize(new Dimension(80,30));
+ splashScreen.addToProgressBar(5);
+ JButton buttonImageForeground = new JButton(LaTeXDrawResources.foregroundIcon);
+ buttonImageForeground.setMargin(INSET_BUTTON);
+ buttonImageForeground.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.70")); //$NON-NLS-1$
+ buttonImageForeground.addActionListener(this);
+ buttonImageForeground.setActionCommand(LaTeXDrawResources.LABEL_FOREGROUND);
+
+ JButton buttonImageBackground = new JButton(LaTeXDrawResources.backgroundIcon);
+ buttonImageBackground.setMargin(INSET_BUTTON);
+ buttonImageBackground.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.71")); //$NON-NLS-1$
+ buttonImageBackground.addActionListener(this);
+ buttonImageBackground.setActionCommand(LaTeXDrawResources.LABEL_BACKGROUND);
+
+ JButton buttonImageFront = new JButton(LaTeXDrawResources.inFrontOfSelIcon);
+ buttonImageFront.setMargin(INSET_BUTTON);
+ buttonImageFront.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.72")); //$NON-NLS-1$
+ buttonImageFront.addActionListener(this);
+ buttonImageFront.setActionCommand(LaTeXDrawResources.LABEL_FRONT_SEL);
+
+ JButton buttonImageBehind = new JButton(LaTeXDrawResources.behindSelIcon);
+ buttonImageBehind.setMargin(INSET_BUTTON);
+ buttonImageBehind.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.73")); //$NON-NLS-1$
+ buttonImageBehind.addActionListener(this);
+ buttonImageBehind.setActionCommand(LaTeXDrawResources.LABEL_BEHIND_SEL);
+
+ rotationButtons = new ListJToggleButton(this, LaTeXDrawResources.rotateIcon, ListJToggleButton.LOCATION_NORTH);
+ rotationButtons.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.2")); //$NON-NLS-1$
+
+ rotateButton = new JToggleButton(LaTeXDrawResources.rotateIcon);
+ rotateButton.setMargin(INSET_BUTTON);
+ rotateButton.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.74")); //$NON-NLS-1$
+ rotateButton.addActionListener(this);
+ rotateButton.setActionCommand(LaTeXDrawResources.LABEL_ROTATE);
+
+ JButton rotate90Button = new JButton(LaTeXDrawResources.rotate90Icon);
+ rotate90Button.setMargin(INSET_BUTTON);
+ rotate90Button.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.3")); //$NON-NLS-1$
+ rotate90Button.addActionListener(this);
+ rotate90Button.setActionCommand(LaTeXDrawResources.LABEL_ROTATE_90);
+
+ JButton rotate180Button = new JButton(LaTeXDrawResources.rotate180Icon);
+ rotate180Button.setMargin(INSET_BUTTON);
+ rotate180Button.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.4")); //$NON-NLS-1$
+ rotate180Button.addActionListener(this);
+ rotate180Button.setActionCommand(LaTeXDrawResources.LABEL_ROTATE_180);
+
+ JButton rotate270Button = new JButton(LaTeXDrawResources.rotate270Icon);
+ rotate270Button.setMargin(INSET_BUTTON);
+ rotate270Button.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.5")); //$NON-NLS-1$
+ rotate270Button.addActionListener(this);
+ rotate270Button.setActionCommand(LaTeXDrawResources.LABEL_ROTATE_270);
+
+ rotationButtons.addComponent(rotateButton);
+ rotationButtons.addComponent(rotate90Button);
+ rotationButtons.addComponent(rotate180Button);
+ rotationButtons.addComponent(rotate270Button);
+ rotationButtons.addSeparator();
+
+ mirrorButtons = new ListJToggleButton(this, LaTeXDrawResources.mirrorHIcon, ListJToggleButton.LOCATION_NORTH);
+ mirrorButtons.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.6")); //$NON-NLS-1$
+
+ JButton button = new JButton(LaTeXDrawResources.mirrorHIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.7")); //$NON-NLS-1$
+ button.addActionListener(this);
+ button.setActionCommand(LaTeXDrawResources.LABEL_MIRROR_H);
+ mirrorButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.mirrorVIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.8")); //$NON-NLS-1$
+ button.addActionListener(this);
+ button.setActionCommand(LaTeXDrawResources.LABEL_MIRROR_V);
+ splashScreen.addToProgressBar(5);
+ mirrorButtons.addComponent(button);
+ mirrorButtons.addSeparator();
+
+ alignButtons = new ListJToggleButton(this, LaTeXDrawResources.alignLeftIcon, ListJToggleButton.LOCATION_NORTH);
+ alignButtons.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.1")); //$NON-NLS-1$
+ ToolbarListener tl = new ToolbarListener(this);
+
+ button = new JButton(LaTeXDrawResources.alignLeftIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.2")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_ALIGN_LEFT);
+ alignButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.alignRightIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.3")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_ALIGN_RIGHT);
+ alignButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.alignTopIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.4")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_ALIGN_TOP);
+ alignButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.alignBottomIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.5")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_ALIGN_BOTTOM);
+ alignButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.alignMiddleHorizIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.6")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_ALIGN_MIDDLE_H);
+ alignButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.alignMiddleVertIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.7")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_ALIGN_MIDDLE_V);
+ alignButtons.addComponent(button);
+ alignButtons.addSeparator();
+
+ distribButtons = new ListJToggleButton(this, LaTeXDrawResources.distVertBottomIcon, ListJToggleButton.LOCATION_NORTH);
+ distribButtons.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.8")); //$NON-NLS-1$
+
+ button = new JButton(LaTeXDrawResources.distVertBottomIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.9")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_DISTRIB_V_BOTTOM);
+ distribButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.distVertEqualIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.10")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_DISTRIB_V_EQ);
+ distribButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.distVertMiddleIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.11")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_DISTRIB_V_MID);
+ distribButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.distVertTopIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.12")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_DISTRIB_V_TOP);
+ distribButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.distHorizLeftIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.13")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_DISTRIB_H_LEFT);
+ distribButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.distHorizEqualIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.14")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_DISTRIB_H_EQ);
+ distribButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.distHorizMiddleIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.15")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_DISTRIB_H_MID);
+ distribButtons.addComponent(button);
+
+ button = new JButton(LaTeXDrawResources.distHorizRightIcon);
+ button.setMargin(INSET_BUTTON);
+ button.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.16")); //$NON-NLS-1$
+ button.addActionListener(tl);
+ button.setActionCommand(ToolbarListener.LABEL_DISTRIB_H_RIGHT);
+ distribButtons.addComponent(button);
+
+ joinButton = new JButton(LaTeXDrawResources.joinIcon);
+ joinButton.setMargin(INSET_BUTTON);
+ joinButton.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.75")); //$NON-NLS-1$
+ joinButton.addActionListener(this);
+ joinButton.setActionCommand(LaTeXDrawResources.LABEL_JOIN);
+
+ separateButton = new JButton(LaTeXDrawResources.separateIcon);
+ separateButton.setMargin(INSET_BUTTON);
+ separateButton.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.76")); //$NON-NLS-1$
+ separateButton.addActionListener(this);
+ separateButton.setActionCommand(LaTeXDrawResources.LABEL_SEPARATE);
+
+ bordersPositionChoice = Figure.createBordersPositionChoice();
+ bordersPositionChoice.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.77")); //$NON-NLS-1$
+ bordersPositionChoice.addItemListener(this);
+ bordersPositionChoice.setPreferredSize(new Dimension(45,30));
+ bordersPositionChoice.setMaximumSize(new Dimension(45,30));
+
+ dbleBoundCheckBox = new JCheckBox(LaTeXDrawResources.LABEL_DBLE_BOUND_CHECKBOX);
+ dbleBoundCheckBox.setMargin(INSET_BUTTON);
+ dbleBoundCheckBox.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.78")); //$NON-NLS-1$
+ dbleBoundCheckBox.setActionCommand(LaTeXDrawResources.LABEL_DBLE_BOUND_CHECKBOX);
+ dbleBoundCheckBox.addActionListener(this);
+
+ buttonDbleBoundColor = new ColorButton(LaTeXDrawResources.LABEL_DBLE_BOUND_CHECKBOX, new ButtonIcon(Figure.DEFAULT_DOUBLE_COLOR));
+ buttonDbleBoundColor.setMargin(INSET_BUTTON);
+ buttonDbleBoundColor.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.79")); //$NON-NLS-1$
+ buttonDbleBoundColor.setActionCommand(LaTeXDrawResources.LABEL_COLOR_DBLE_BOUND);
+ buttonDbleBoundColor.addActionListener(this);
+ genDbleBordCB = new ColorButton(LaTeXDrawResources.LABEL_DBLE_BOUND_CHECKBOX, new ButtonIcon(Figure.DEFAULT_DOUBLE_COLOR));
+ genDbleBordCB.setMargin(INSET_BUTTON);
+ genDbleBordCB.setToolTipText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.79")); //$NON-NLS-1$
+ genDbleBordCB.setActionCommand(LaTeXDrawResources.LABEL_COLOR_DBLE_BOUND);
+ genDbleBordCB.addActionListener(this);
+
+ stopButton = new JButton(LaTeXDrawResources.stopIcon);
+ stopButton.setMargin(INSET_BUTTON);
+ stopButton.setActionCommand(LaTeXDrawResources.LABEL_STOP);
+ stopButton.addActionListener(this);
+ stopButton.setName(LaTeXDrawResources.LABEL_STOP);
+ stopButton.setToolTipText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.9")); //$NON-NLS-1$
+ stopButton.setVisible(false);
+
+ shadowCheckBox = new JCheckBox(LaTeXDrawResources.LABEL_SHADOW_CHECKBOX);
+ shadowCheckBox.setMargin(INSET_BUTTON);
+ shadowCheckBox.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.4")); //$NON-NLS-1$
+ shadowCheckBox.setActionCommand(LaTeXDrawResources.LABEL_SHADOW_CHECKBOX);
+ shadowCheckBox.addActionListener(this);
+
+ buttonShadowColor = new ColorButton(LaTeXDrawResources.LABEL_COLOR_SHADOW, new ButtonIcon(Figure.DEFAULT_SHADOW_COLOR));
+ buttonShadowColor.setMargin(INSET_BUTTON);
+ buttonShadowColor.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.5")); //$NON-NLS-1$
+ buttonShadowColor.setActionCommand(LaTeXDrawResources.LABEL_COLOR_SHADOW);
+ buttonShadowColor.addActionListener(this);
+ genShadowCB = new ColorButton(LaTeXDrawResources.LABEL_COLOR_SHADOW, new ButtonIcon(Figure.DEFAULT_SHADOW_COLOR));
+ genShadowCB.setMargin(INSET_BUTTON);
+ genShadowCB.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.5")); //$NON-NLS-1$
+ genShadowCB.setActionCommand(LaTeXDrawResources.LABEL_COLOR_SHADOW);
+ genShadowCB.addActionListener(this);
+
+ labelThickness = new JLabel(LaTeXDrawResources.thicknessIcon);
+ locationButtons = new ListJToggleButton(this, LaTeXDrawResources.foregroundIcon, ListJToggleButton.LOCATION_NORTH);
+ locationButtons.addComponent(buttonImageForeground);
+ locationButtons.addComponent(buttonImageBackground);
+ locationButtons.addComponent(buttonImageFront);
+ locationButtons.addComponent(buttonImageBehind);
+ locationButtons.addSeparator();
+ locationButtons.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.6")); //$NON-NLS-1$
+
+ buttonGradientStartC = new ColorButton(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR));
+ buttonGradientStartC.setMargin(INSET_BUTTON);
+ buttonGradientStartC.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.7")); //$NON-NLS-1$
+ buttonGradientStartC.setActionCommand(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST);
+ buttonGradientStartC.addActionListener(this);
+ genGradientStartCB = new ColorButton(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR));
+ genGradientStartCB.setMargin(INSET_BUTTON);
+ genGradientStartCB.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.7")); //$NON-NLS-1$
+ genGradientStartCB.setActionCommand(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST);
+ genGradientStartCB.addActionListener(this);
+
+ buttonGradientEndC = new ColorButton(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR));
+ buttonGradientEndC.setMargin(INSET_BUTTON);
+ buttonGradientEndC.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.8")); //$NON-NLS-1$
+ buttonGradientEndC.setActionCommand(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND);
+ buttonGradientEndC.addActionListener(this);
+ genGradientEndCB = new ColorButton(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND, new ButtonIcon(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR));
+ genGradientEndCB.setMargin(INSET_BUTTON);
+ genGradientEndCB.setToolTipText(LaTeXDrawLang.getString1_7("LaTeXDrawFrame.8")); //$NON-NLS-1$
+ genGradientEndCB.setActionCommand(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND);
+ genGradientEndCB.addActionListener(this);
+ splashScreen.addToProgressBar(5);
+
+ initializeGeneralFields();
+ genColorL = new ListJToggleButton(this, LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.17"), ListJToggleButton.LOCATION_NORTH); //$NON-NLS-1$
+ genColorL.addComponent(genLineCB);
+ genColorL.addComponent(genInteriorCB);
+ genColorL.addComponent(genHatchCB);
+ genColorL.addComponent(genDbleBordCB);
+ genColorL.addComponent(genShadowCB);
+ genColorL.addComponent(genGradientStartCB);
+ genColorL.addComponent(genGradientEndCB);
+
+ paramsToolbar.add(progressBar);
+ paramsToolbar.add(stopButton);
+ paramsToolbar.add(rotationButtons);
+ paramsToolbar.add(locationButtons);
+ paramsToolbar.add(mirrorButtons);
+ paramsToolbar.add(alignButtons);
+ paramsToolbar.add(distribButtons);
+ paramsToolbar.add(joinButton);
+ paramsToolbar.add(separateButton);
+ paramsToolbar.add(labelThickness);
+ paramsToolbar.add(thicknessField);
+ paramsToolbar.add(labelDotSize);
+ paramsToolbar.add(dotSizeField);
+ paramsToolbar.add(genColorL);
+ paramsToolbar.add(buttonBordersColor);
+ paramsToolbar.add(filledCheckBox);
+ paramsToolbar.add(buttonInteriorColor);
+ paramsToolbar.add(hatchChoice);
+ paramsToolbar.add(buttonGradientStartC);
+ paramsToolbar.add(buttonGradientEndC);
+ paramsToolbar.add(buttonHatchColor);
+ paramsToolbar.add(dotChoice);
+ paramsToolbar.add(lineChoice);
+ paramsToolbar.add(lineArrowLChoice);
+ paramsToolbar.add(lineArrowRChoice);
+ paramsToolbar.add(bordersPositionChoice);
+ paramsToolbar.add(dbleBoundCheckBox);
+ paramsToolbar.add(buttonDbleBoundColor);
+ paramsToolbar.add(shadowCheckBox);
+ paramsToolbar.add(buttonShadowColor);
+
+ JPanel southPanel = new JPanel();
+ southPanel.setLayout(new BorderLayout());
+ southPanel.add(paramsToolbar, BorderLayout.CENTER);
+ southPanel.add(statusBar, BorderLayout.SOUTH);
+ getContentPane().add(southPanel, BorderLayout.SOUTH);
+ splashScreen.addToProgressBar(5);
+ preferencesFrame = new PreferencesFrame(draw, this);
+ formerIsInAutoUpdate = preferencesFrame.isCodeInAutoUpdate();
+ convertFrame.setPathSelect(pathOpen);
+ convertFrame.setPathOutput(pathExport);
+ codePanel.setIsInAutoUpdate(formerIsInAutoUpdate);
+ recentFilesListener = new RecentFilesListener(preferencesFrame, this);
+ shortcutsListener = new ShortcutsListener(this);
+ addKeyListener(shortcutsListener);
+
+ drawPanel.isSelection(false);
+ setTitle(LaTeXDrawResources.LABEL_APP);
+ setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+
+ addWindowListener(
+ new WindowAdapter()
+ {
+ @Override
+ public void windowClosing(WindowEvent e)
+ {
+ onWindowClosing();
+ }
+ });
+
+ setCurrentChoice(LaTeXDrawResources.LABEL_SELECT_FIGURE);
+ setSelection(false);
+
+ boolean fileIsOk = true;
+ /* Management of command line */
+ if(args.length>0)
+ {
+ if(args.length>1)
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.81")); //$NON-NLS-1$
+
+ if(args[0].toLowerCase().endsWith(TeXFilter.TEX_EXTENSION))
+ fileIsOk = importPSTricksFile(args[0]);
+ else
+ fileIsOk = open(args[0], false);
+ }
+
+ menuBar.updateRecentFilesMenu();
+ drawPanel.setIsModified(false);
+ splashScreen.addToProgressBar(5);
+
+ if(checkNewVersion && WITH_UPDATE)
+ {
+ VersionChecker vc = new VersionChecker(this);
+ vc.start();
+ }
+
+ addWindowStateListener(this);
+ splashScreen.setVisible(false);
+ setVisible(true);
+ updateSplitSeparatorPosition();
+ toolbar.getSliderDelimitor().setValue(Delimitor.getOpacity());
+
+ if(!fileIsOk)
+ JOptionPane.showMessageDialog(this, LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.18"), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.86"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
+ }
+ catch(Exception e1)
+ {
+ splashScreen.setVisible(false);
+ JOptionPane.showMessageDialog(this, LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.82") + //$NON-NLS-1$
+ e1.toString(), LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.83"), //$NON-NLS-1$
+ JOptionPane.WARNING_MESSAGE);
+ e1.printStackTrace();
+ LaTeXDrawFrame.this.windowClosed();
+ }
+ }
+
+
+
+ /**
+ * @return Returns the versionOfFile.
+ */
+ public static String getVersionOfFile()
+ {
+ return versionOfFile;
+ }
+
+
+ public static void setVersionOfFile(String v)
+ {
+ if(v!=null)
+ versionOfFile = v;
+ }
+
+
+ /**
+ * Defines actions to do on window closing
+ */
+ public void onWindowClosing()
+ {
+ getPreferencesFrame().writeXMLPreferences(false);
+
+ try
+ {
+ if(drawPanel.isModified())
+ {
+ int id = dialogConfirmSave();
+
+ switch(id)
+ {
+ case JOptionPane.YES_OPTION :
+ if(save(false))
+ LaTeXDrawFrame.this.windowClosed();
+ break;
+ case JOptionPane.NO_OPTION :
+ LaTeXDrawFrame.this.windowClosed();
+ break;
+ case JOptionPane.CANCEL_OPTION : return;
+ default : return;
+ }
+ }
+ else LaTeXDrawFrame.this.windowClosed();
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(ex);
+ }
+ }
+
+
+
+
+ /**
+ * Allows to show the frame which allows to change the parameters of
+ * a figure
+ * @param f The figure we want to display its parameters
+ */
+ public void showParamFrame(Figure f, boolean deleteOnCancel)
+ {
+ try
+ {
+ if(f==null)
+ return ;
+
+ if(f instanceof BezierCurve)
+ {
+ if(paramBezierCurveFrame==null)
+ paramBezierCurveFrame = new ParametersBezierCurveFrame(this, drawPanel, true);
+
+ paramBezierCurveFrame.setVisible(true, f, deleteOnCancel, false);
+ }else
+ if(f instanceof AkinPoints)
+ {
+ if(paramAkinPointsFrame==null)
+ paramAkinPointsFrame = new ParametersAkinPointsFrame(this, drawPanel, true);
+
+ paramAkinPointsFrame.setVisible(true, f, deleteOnCancel, false);
+ }else
+ if(f instanceof Line)
+ {
+ if(paramLineFrame==null)
+ paramLineFrame = new ParametersLineFrame(this, drawPanel, true);
+
+ paramLineFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof Arc)
+ {
+ if(paramArcFrame==null)
+ paramArcFrame = new ParametersArcFrame(this, drawPanel, true);
+
+ paramArcFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof Axe)
+ {
+ if(paramAxesFrame==null)
+ paramAxesFrame = new ParametersAxeFrame(this, drawPanel, true);
+
+ paramAxesFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof Circle || f instanceof Square)
+ {
+ if(paramCircleFrame==null)
+ paramCircleFrame = new ParametersCircleSquareFrame(this, drawPanel, true);
+
+ paramCircleFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof Ellipse || f instanceof LaTeXDrawRectangle)
+ {
+ if(paramEllipseFrame==null)
+ paramEllipseFrame = new ParametersEllipseRectangleFrame(this, drawPanel, true);
+
+ paramEllipseFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof Dot)
+ {
+ if(paramDotFrame==null)
+ paramDotFrame = new ParametersDotFrame(this, drawPanel, true);
+
+ paramDotFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof Triangle)
+ {
+ if(paramTriangleFrame==null)
+ paramTriangleFrame = new ParametersTriangleFrame(this, drawPanel, true);
+
+ paramTriangleFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof Rhombus)
+ {
+ if(paramRhombusFrame==null)
+ paramRhombusFrame = new ParametersRhombusFrame(this, drawPanel, true);
+
+ paramRhombusFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof JoinedLines)
+ {
+ if(paramJoinedLinesFrame==null)
+ paramJoinedLinesFrame = new ParametersPolygonJoinedLinesFrame(this, drawPanel, false, true);
+
+ paramJoinedLinesFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof LaTeXDrawPolygon)
+ {
+ if(paramPolygonFrame==null)
+ paramPolygonFrame = new ParametersPolygonJoinedLinesFrame(this, drawPanel, true, true);
+
+ paramPolygonFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof Text)
+ {
+ if(paramTextFrame==null)
+ paramTextFrame = new ParametersTextFrame(this, drawPanel, true);
+
+ paramTextFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+ else if(f instanceof Grid)
+ {
+ if(paramGridFrame==null)
+ paramGridFrame = new ParametersGridFrame(this, drawPanel, true);
+
+ paramGridFrame.setVisible(true, f, deleteOnCancel, false);
+ }
+// else if(f instanceof Draw)
+// {
+// if(paramDrawFrame==null)
+// paramDrawFrame = new ParametersDrawFrame(this, drawPanel, true);
+//
+// paramDrawFrame.setVisible(true, f, deleteOnCancel, false);
+// }
+
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+ }
+
+
+
+
+ /**
+ * Allows to get the undo/redo manager
+ * @return The undo/redo manager
+ */
+ public UndoRedoManager getUndoManager()
+ {
+ return undoManager;
+ }
+
+
+
+ /**
+ * Allows to set the name of the application
+ */
+ public void setTitle()
+ {
+ if(projectName==null)
+ super.setTitle(LaTeXDrawResources.LABEL_APP);
+ else super.setTitle(LaTeXDrawResources.LABEL_APP + " - " + projectName + (drawPanel.isModified() ? "*" : ""));//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+
+
+
+ /**
+ * Allows to update some fields when a figure is selected or not.
+ * @param onSelection True : a figure is selected.
+ */
+ public void setSelection(boolean onSelection)
+ {
+ Draw listSelected = drawPanel.getDraw().getSelected();
+ boolean empty = listSelected==null || listSelected.isEmpty();
+
+ menuBar.getExportTemplateMenu().setEnabled(onSelection && !empty);
+ menuBar.getDeleteFigure().setEnabled(onSelection && !empty);
+ menuBar.getPropertiesFigureMenu().setEnabled(onSelection && !empty);
+ toolbar.getButtonImageProperties().setEnabled(onSelection && !empty);
+ toolbar.getButtonImageDel().setEnabled(onSelection && !empty);
+ locationButtons.setVisible(onSelection && !empty);
+ rotationButtons.setVisible(onSelection && !empty);
+ mirrorButtons.setVisible(onSelection && !empty);
+ alignButtons.setVisible(onSelection && listSelected!=null && listSelected.size()>1);
+ distribButtons.setVisible(onSelection && listSelected!=null && listSelected.size()>2);
+ menuBar.getCopyMenu().setEnabled(onSelection && !empty);
+ menuBar.getCutMenu().setEnabled(onSelection && !empty);
+ toolbar.getCopyCodeSelButton().setEnabled(onSelection && !empty);
+
+ if(onSelection && listSelected!=null && listSelected.size()==1 && listSelected.getFigureAt(0).isCustomizable() &&
+ !(listSelected.getFigureAt(0) instanceof Draw))
+ {
+ toolbar.getButtonImageProperties().setEnabled(true);
+ joinButton.setVisible(false);
+ buttonBordersColor.setVisible(true);
+ separateButton.setVisible(listSelected.getFigureAt(0) instanceof Draw ? true : false);
+
+ Figure selected = listSelected.getFigureAt(0);
+
+ if(selected != null)
+ {
+ if(selected instanceof Dot)
+ {
+ dotChoice.setVisible(true);
+ // A dot can always filled, or it cannot be filled.
+ filledCheckBox.setVisible(false);
+ buttonInteriorColor.setVisible(selected.canBeFilled());
+ labelDotSize.setVisible(true);
+ dotSizeField.setVisible(true);
+ }
+ else
+ {
+ labelDotSize.setVisible(false);
+ dotSizeField.setVisible(false);
+ dotChoice.setVisible(false);
+ filledCheckBox.setVisible(selected.canBeFilled() && !selected.hasGradient());
+ } //else
+
+ buttonInteriorColor.setVisible(selected.canBeFilled() && (selected.isFilled() || selected.hasShadow()) &&
+ !selected.hasGradient() && selected.shadowFillsShape());
+ lineArrowLChoice.setVisible(selected.canHaveArrow());
+ lineArrowRChoice.setVisible(selected.canHaveArrow());
+ shadowCheckBox.setVisible(selected.canHaveShadow());
+ buttonShadowColor.setVisible(selected.hasShadow());
+ dbleBoundCheckBox.setVisible(selected.isDoubleBoundaryable());
+ buttonDbleBoundColor.setVisible(dbleBoundCheckBox.isSelected());
+ bordersPositionChoice.setVisible(selected.isBordersMovable());
+ labelThickness.setVisible(selected.isThicknessable());
+ thicknessField.setVisible(selected.isThicknessable());
+ lineChoice.setVisible(selected.isDashableOrDotable());
+ hatchChoice.setVisible(selected.canBeHatched());
+ buttonGradientEndC.setVisible(selected.canBeHatched() && selected.hasGradient());
+ buttonGradientStartC.setVisible(buttonGradientEndC.isVisible());
+ buttonHatchColor.setVisible(selected.canBeHatched() && selected.isHatched());
+ }
+ genColorL.setVisible(false);
+ }// if(onSelection)
+ else
+ {
+ if(listSelected!=null && (listSelected.size()!=1 || (!listSelected.getFigureAt(0).isCustomizable() &&
+ !(listSelected.getFigureAt(0) instanceof Draw))))
+ {
+ toolbar.getButtonImageProperties().setEnabled(false);
+ menuBar.getPropertiesFigureMenu().setEnabled(false);
+ }
+
+ toolbar.getButtonImageProperties().setEnabled(false);
+ dbleBoundCheckBox.setVisible(true);
+ buttonDbleBoundColor.setVisible(false);
+ bordersPositionChoice.setVisible(true);
+ buttonBordersColor.setVisible(false);
+ labelThickness.setVisible(true);
+ buttonHatchColor.setVisible(false);
+ buttonInteriorColor.setVisible(false);
+ hatchChoice.setVisible(true);
+ buttonHatchColor.setVisible(false);
+ dotChoice.setVisible(true);
+ lineChoice.setVisible(true);
+ lineArrowLChoice.setVisible(true);
+ lineArrowRChoice.setVisible(true);
+ thicknessField.setVisible(true);
+ buttonShadowColor.setVisible(false);
+ shadowCheckBox.setVisible(true);
+ buttonGradientEndC.setVisible(false);
+ buttonGradientStartC.setVisible(false);
+ filledCheckBox.setVisible(true);
+ genColorL.setVisible(true);
+ dotSizeField.setVisible(true);
+ labelDotSize.setVisible(true);
+
+ joinButton.setVisible(listSelected!=null && listSelected.size()>1);
+ separateButton.setVisible(listSelected!=null && listSelected.size()==1 && listSelected.getFigureAt(0) instanceof Draw);
+ }
+
+ updateFrameFields();
+ }
+
+
+
+
+ /**
+ * Initialises the toolbar of the application.
+ */
+ private void createToolbar()
+ {
+ toolbar = new LToolbar(this);
+ requestFocus();
+ }
+
+
+
+ /**
+ * Allows to get the path for open/save actions
+ * @return The path for open/save actions
+ */
+ public static String getPathExport()
+ {
+ return pathExport;
+ }
+
+
+
+
+ /**
+ * Allows to get the path for exportation actions
+ * @return The path for exportation actions
+ */
+ public static String getPathOpen()
+ {
+ return pathOpen;
+ }
+
+
+
+
+ /**
+ * Allows to get the current choice of the user
+ * @return The current choice of the user
+ */
+ public String getCurrentChoice()
+ {
+ return currentChoice;
+ }
+
+
+
+ /**
+ * Allows to get the codePanel
+ * @return The codePanel
+ */
+ public CodePanel getCodePanel()
+ {
+ return codePanel;
+ }
+
+
+
+ /**
+ * Allows to get the drawPanel
+ * @return The drawPanel
+ */
+ public DrawPanel getDrawPanel()
+ {
+ return drawPanel;
+ }
+
+
+
+ /**
+ * Allows to set if the grid must be displayed.
+ * @param display True : the grid must be displayed.
+ * @param classicGrid Define if it is the classic grid which must be drawn (only if display=true).
+ */
+ public void displayGrid(boolean display, boolean classicGrid)
+ {
+ if(display)
+ {
+ menuBar.getDisplayGrid().setSelected(classicGrid);
+ toolbar.getPersoGridGapField().setEnabled(!classicGrid);
+ menuBar.getDisplayPersoGrid().setSelected(!classicGrid);
+ drawPanel.draw.setClassicGridDrawn(classicGrid);
+ }
+ else
+ {
+ menuBar.getDisplayGrid().setSelected(false);
+ toolbar.getPersoGridGapField().setEnabled(false);
+ menuBar.getDisplayPersoGrid().setSelected(false);
+ }
+
+ drawPanel.setIsGridDisplay(display);
+ drawPanel.setIsModified(true);
+ }
+
+
+
+ /**
+ * Allows to set if the XScale must be displayed
+ * @param display True : the XScale must be displayed
+ */
+ public void displayXScale(boolean display)
+ {
+ menuBar.getDisplayXScale().setSelected(display);
+ xScale.setVisible(display);
+
+ try {drawPanel.setIsModified(true);}
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+
+ menuBar.getDisplayXScale().setSelected(display);
+ }
+
+
+
+ /**
+ * Allows to set if the YScale must be displayed
+ * @param display True : the YScale must be displayed
+ */
+ public void displayYScale(boolean display)
+ {
+ yScale.setVisible(display);
+
+ try {drawPanel.setIsModified(true);}
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+
+ menuBar.getDisplayYScale().setSelected(display);
+ }
+
+
+
+
+ /**
+ * Allows to set if the borders of the drawing must be displayed
+ * @param display True : the borders of the drawing must be displayed
+ */
+ public void displayBorders(boolean display)
+ {
+ try
+ {
+ drawPanel.displayBorders(display);
+ menuBar.getDisplayBorders().setSelected(display);
+ toolbar.getButtonImageBorders().setSelected(display);
+ drawPanel.setIsModified(true);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+ }
+
+
+
+
+
+ /**
+ * Allows to set if the code panel must be displayed
+ * @param display True: the code panel must be displayed
+ */
+ public void displayCodePanel(boolean display)
+ {
+ menuBar.getDisplayCodePanel().setSelected(display);
+ toolbar.getCopyCodeButton().setVisible(!display);
+
+ if(display)
+ {
+ codePanel.setVisible(true);
+ codePanel.setIsInAutoUpdate(formerIsInAutoUpdate);
+ splitPane.setDividerLocation(formerDividerLocation);
+ }
+ else
+ {
+ formerIsInAutoUpdate = codePanel.isInAutoUpdate();
+ codePanel.setIsInAutoUpdate(false);
+ formerDividerLocation = splitPane.getDividerLocation();
+ codePanel.setVisible(false);
+ }
+
+ splitPane.revalidate();
+ }
+
+
+
+ /**
+ * Allows to set the path for open/save actions
+ * @param path The new path
+ */
+ public void setPathOpen(String path)
+ {
+ pathOpen = path;
+ if(fileChooserSave!=null)
+ fileChooserSave.setCurrentDirectory(new File(path));
+ }
+
+
+
+
+ /**
+ * Allows to set the path for exportations actions
+ * @param path The new path
+ */
+ public void setPathExport(String path)
+ {
+ pathExport = path;
+ if(fileChooserExport!=null)
+ fileChooserExport.setCurrentDirectory(new File(path));
+ }
+
+
+
+
+ /**
+ * Allows to set if the menu "paste" must be enable or not
+ * @param mustBeEnable True : the menu "paste" must be activated
+ */
+ public void setMenuPaste(boolean mustBeEnable)
+ {
+ getLMenuBar().getPasteMenu().setEnabled(mustBeEnable);
+ }
+
+
+
+
+ /**
+ * Allows to set if the menu "copy" must be enable or not
+ * @param mustBeEnable True : the menu "copy" must be activated
+ */
+ public void setMenuCopy(boolean mustBeEnable)
+ {
+ getLMenuBar().getCopyMenu().setEnabled(mustBeEnable);
+ }
+
+
+
+
+ /**
+ * Allows to set the selected field of the choice lineChoice
+ * @param choice The new selected choice
+ */
+ public void setLineChoice(String choice)
+ {
+ if(!Figure.isValidStyle(choice))
+ throw new IllegalArgumentException();
+
+ lineChoice.removeItemListener(this);
+ lineChoice.setSelectedItem(choice);
+ lineChoice.addItemListener(this);
+ }
+
+
+
+ /**
+ * Allows to set the selected field of the choice <code>bordersPositionChoice</code>.
+ * @param choice The new choice.
+ * @since 1.9.1
+ */
+ public void setBorderChoice(String choice)
+ {
+ bordersPositionChoice.removeItemListener(this);
+ bordersPositionChoice.setSelectedItem(choice);
+ bordersPositionChoice.addItemListener(this);
+ }
+
+
+
+ /**
+ * Allows to set the selected field of the choice <code>hatchChoice</code>.
+ * @param choice The new choice.
+ * @since 1.9.1
+ */
+ public void setHatchChoice(String choice)
+ {
+ hatchChoice.removeItemListener(this);
+ hatchChoice.setSelectedItem(choice);
+ hatchChoice.addItemListener(this);
+ }
+
+
+
+ /**
+ * Allows to set the selected field of the choice lineArrowRChoice
+ * @param choice The new selected choice
+ */
+ public void setLineArrowRChoice(String choice)
+ {
+ if(!PSTricksConstants.isValidArrowStyle(choice))
+ throw new IllegalArgumentException();
+
+ lineArrowRChoice.removeItemListener(this);
+ lineArrowRChoice.setSelectedItem(choice);
+ lineArrowRChoice.addItemListener(this);
+ }
+
+
+
+
+ /**
+ * Allows to set the selected field of the choice lineArrowLChoice
+ * @param choice The new selected choice
+ */
+ public void setLineArrowLChoice(String choice)
+ {
+ if(!PSTricksConstants.isValidArrowStyle(choice))
+ throw new IllegalArgumentException();
+
+ lineArrowLChoice.removeItemListener(this);
+ lineArrowLChoice.setSelectedItem(choice);
+ lineArrowLChoice.addItemListener(this);
+ }
+
+
+
+
+ /**
+ * Allows to update the selected field in the Choice component
+ * dotChoice
+ * @param newChoice The choice which must be selected
+ */
+ public void setDotChoice(String newChoice)
+ {
+ if(!PSTricksConstants.isValidDotStyle(newChoice))
+ throw new IllegalArgumentException();
+
+ dotChoice.removeItemListener(this);
+ dotChoice.setSelectedItem(newChoice);
+ dotChoice.addItemListener(this);
+ }
+
+
+
+
+ /**
+ * Allows to set the menu exportAs able or not
+ * @param state It's new state
+ */
+ public void setExportAsMenu(boolean state)
+ {
+ getLMenuBar().getExportAsMenu().setEnabled(state);
+ }
+
+
+
+ /**
+ * Allows to set the value of the field thickness
+ * @param thickness The new value of the field thickness
+ */
+ public void setThicknessFieldValue(float thickness)
+ {
+ thicknessField.removeChangeListener(this);
+ thicknessField.setValue(Float.valueOf(thickness).doubleValue());
+ thicknessField.addChangeListener(this);
+ }
+
+
+
+ public void setDotFieldValue(float width)
+ {
+ dotSizeField.removeChangeListener(this);
+ dotSizeField.setValue(Float.valueOf(width).doubleValue());
+ dotSizeField.addChangeListener(this);
+ }
+
+
+ /**
+ * Allows to set the attribute "isModified" in the drawPanel
+ * @param modified The new value of the attribute "isModified"
+ */
+ public void setIsModified(boolean modified)
+ {
+ drawPanel.setIsModified(modified);
+ }
+
+
+
+
+ /**
+ * Allows to reinitialise some buttons
+ */
+ public void reinitializeButtons()
+ {
+ updateUndoRedo();
+ codePanel.newProject();
+ Delimitor.setOpacity(Delimitor.DEFAULT_OPACITY);
+ toolbar.getSliderDelimitor().setValue(Delimitor.DEFAULT_OPACITY);
+ toolbar.getPersoGridGapField().setValue(MagneticGrid.DEFAULT_PERSONAL_GRID_GAP);
+ menuBar.getDisplayGrid().setSelected(false);
+ menuBar.getDisplayPersoGrid().setSelected(false);
+ toolbar.getPersoGridGapField().setEnabled(false);
+ toolbar.getMagneticCB().setSelected(false);
+ rotationButtons.setSelected(false);
+ mirrorButtons.setSelected(false);
+ drawPanel.setOnRotation(false);
+ preferencesFrame.readXMLPreferences();
+ if(drawPropertiesFrame!=null)
+ drawPropertiesFrame.setProperties();
+ toolbar.getButtonImageSelect().setSelected(true);
+ menuBar.getMenuSelect().setSelected(true);
+ menuBar.getAutoAdjustBorders().setSelected(true);
+ drawPanel.setMenuSelectedPopupGeneral(menuBar.getMenuSelect().getActionCommand(),true);
+ rotateButton.setSelected(false);
+ drawPanel.setOnRotation(false);
+ setCurrentChoice(LaTeXDrawResources.LABEL_SELECT_FIGURE);
+ }
+
+
+
+
+ /**
+ * Allows to update buttons undo/redo
+ * (change their titles, ...)
+ */
+ public void updateUndoRedo()
+ {
+ if(undoManager.isEmptyRedo())
+ {
+ toolbar.getButtonImageRedo().setToolTipText(UndoRedoManager.EMPTY_REDO);
+ menuBar.getRedoMenu().setText(UndoRedoManager.EMPTY_REDO);
+ }
+ else
+ {
+ toolbar.getButtonImageRedo().setToolTipText(LaTeXDrawResources.LABEL_REDO +" " +undoManager.getTextNextRedo());//$NON-NLS-1$
+ menuBar.getRedoMenu().setText(LaTeXDrawResources.LABEL_REDO +" " +undoManager.getTextNextRedo());//$NON-NLS-1$
+ }
+
+ if(undoManager.isEmptyUndo())
+ {
+ menuBar.getUndoMenu().setText(UndoRedoManager.EMPTY_UNDO);
+ toolbar.getButtonImageUndo().setToolTipText(UndoRedoManager.EMPTY_UNDO);
+ }
+ else
+ {
+ menuBar.getUndoMenu().setText(LaTeXDrawResources.LABEL_UNDO +" " +undoManager.getTextNextUndo());//$NON-NLS-1$
+ toolbar.getButtonImageUndo().setToolTipText(LaTeXDrawResources.LABEL_UNDO +" " +undoManager.getTextNextUndo());//$NON-NLS-1$
+ }
+
+ menuBar.getUndoMenu().setEnabled(!undoManager.isEmptyUndo());
+ menuBar.getRedoMenu().setEnabled(!undoManager.isEmptyRedo());
+ toolbar.getButtonImageRedo().setEnabled(!undoManager.isEmptyRedo());
+ toolbar.getButtonImageUndo().setEnabled(!undoManager.isEmptyUndo());
+ }
+
+
+
+
+ /**
+ * Allows to update fields of the frame : if a figure is selected, its parameters are updated, else general parameters are used
+ * to set the fields.
+ */
+ public void updateFrameFields()
+ {
+ try
+ {
+ Draw listSelected = drawPanel.getDraw().getSelected();
+
+ if(listSelected!=null && listSelected.size()==1)
+ {
+ Figure f = listSelected.getFigureAt(0);
+
+ if(f!=null)
+ {
+ if(f instanceof Dot)
+ {
+ setDotFieldValue(((Dot)f).getWidth());
+ setDotChoice(((Dot)f).getCurrentStyle());
+ buttonInteriorColor.setVisible(f.canBeFilled());
+ }
+ else
+ {
+ if(f.canHaveArrow())
+ {
+ setLineArrowLChoice(((Arrowable)f).getArrow1Style());
+ setLineArrowRChoice(((Arrowable)f).hasTwoLeftArrows() ?
+ ArrowHead.invertArrowStyle(((Arrowable)f).getArrow2Style()) : ((Arrowable)f).getArrow2Style());
+ }
+
+ setThicknessFieldValue(f.getThickness());
+ setLineChoice(f.getLineStyle());
+ filledCheckBox.setSelected(f.canBeFilled() && f.isFilled());
+ }
+
+ buttonBordersColor.setColor(f.getLinesColor());
+ setHatchChoice(f.getHatchingStyle());
+ dbleBoundCheckBox.setSelected(f.isDoubleBoundaryable() && f.hasDoubleBoundary());
+ shadowCheckBox.setSelected(f.hasShadow());
+ updateFillCB();
+
+ if(f.canHaveShadow())
+ buttonShadowColor.setColor(f.getShadowColor());
+
+ if(f.canBeFilled())
+ {
+ buttonBordersColor.setColor(f.getLinesColor());
+ buttonInteriorColor.setColor(f.getInteriorColor());
+ buttonGradientEndC.setColor(f.getGradientEndColor());
+ buttonGradientStartC.setColor(f.getGradientStartColor());
+ }
+
+ if(f.canBeHatched())
+ buttonHatchColor.setColor(f.getHatchingColor());
+
+ if(f.isDoubleBoundaryable())
+ buttonDbleBoundColor.setColor(f.getDoubleColor());
+
+ if(f.isBordersMovable())
+ setBorderChoice(f.getBordersPosition());
+ }//if
+ }
+ else
+ if(listSelected!=null && listSelected.size()>1)
+ {// We try to identify the figures' attributes that are equals.
+ boolean ok;
+ int i, size = listSelected.size();
+ Color linesC = listSelected.getFigureAt(0).getLinesColor();
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).isDoubleBoundaryable())
+ ok = false;
+
+ if(!ok)
+ {
+ boolean hasDbleBound = listSelected.getFigureAt(i-1).hasDoubleBoundary();
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).isDoubleBoundaryable() &&
+ listSelected.getFigureAt(i).hasDoubleBoundary()!=hasDbleBound)
+ ok = false;
+
+ dbleBoundCheckBox.setSelected(ok ? hasDbleBound : genHasDbleBord);
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).hasDoubleBoundary())
+ ok = false;
+
+ if(!ok)
+ {
+ Color dbleC = listSelected.getFigureAt(i-1).getDoubleColor();
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).hasDoubleBoundary() &&
+ !listSelected.getFigureAt(i).getDoubleColor().equals(dbleC))
+ ok = false;
+
+ genDbleBordCB.setColor(ok ? dbleC : genDbleC);
+ }
+ else
+ genDbleBordCB.setColor(genDbleC);
+ }
+ else
+ dbleBoundCheckBox.setSelected(genHasDbleBord);
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i) instanceof Arrowable)
+ ok = false;
+
+ if(!ok)
+ {
+ Arrowable arr = ((Arrowable)listSelected.getFigureAt(i-1));
+ String arrow1S = arr.getArrow1Style();
+ String arrow2S = arr.hasTwoLeftArrows() ? ArrowHead.invertArrowStyle(arr.getArrow2Style()) : arr.getArrow2Style();
+ boolean ok2 = true;
+ String str;
+
+ for(i=0, ok=true; i<size; i++)
+ if(listSelected.getFigureAt(i) instanceof Arrowable)
+ {
+ Arrowable a = (Arrowable)listSelected.getFigureAt(i);
+ str = a.getArrow2Style();
+
+ if(a.hasTwoLeftArrows())
+ str = ArrowHead.invertArrowStyle(str);
+
+ if(!a.getArrow1Style().equals(arrow1S))
+ ok = false;
+
+ if(!str.equals(arrow2S))
+ ok2 = false;
+ }
+
+ setLineArrowLChoice(ok ? arrow1S : genLeftArrS);
+ setLineArrowRChoice(ok2 ? arrow2S : genRightArrS);
+ }
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i) instanceof Dot)
+ ok = false;
+
+ if(!ok)
+ {
+ String dotStyle = ((Dot)listSelected.getFigureAt(i-1)).getCurrentStyle();
+ float width = ((Dot)listSelected.getFigureAt(i-1)).getWidth();
+ boolean ok2 = true;
+
+ for(i=0, ok=true; i<size; i++)
+ if(listSelected.getFigureAt(i) instanceof Dot)
+ {
+ Dot d = (Dot)listSelected.getFigureAt(i);
+
+ if(!d.getCurrentStyle().equals(dotStyle))
+ ok = false;
+
+ if(d.getWidth()!=width)
+ ok2 = false;
+ }
+
+ setDotChoice(ok ? dotStyle : genDotS);
+ setDotFieldValue(ok2 ? width : genDotSize);
+ }
+ else setLineChoice(genLineStyleS);
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).isDashableOrDotable())
+ ok = false;
+
+ if(!ok)
+ {
+ String lineStyle = listSelected.getFigureAt(i-1).getLineStyle();
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).isDashableOrDotable() &&
+ !listSelected.getFigureAt(i).getLineStyle().equals(lineStyle))
+ ok = false;
+
+ setLineChoice(ok ? lineStyle : genLineStyleS);
+ }
+ else setLineChoice(genLineStyleS);
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).isBordersMovable())
+ ok = false;
+
+ if(!ok)
+ {
+ String bordPos = listSelected.getFigureAt(i-1).getBordersPosition();
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).isBordersMovable() &&
+ !listSelected.getFigureAt(i).getBordersPosition().equals(bordPos))
+ ok = false;
+
+ setBorderChoice(ok ? bordPos : genBordPosS);
+ }
+ else setBorderChoice(genBordPosS);
+
+ for(i=1; i<size && ok; i++)
+ if(!listSelected.getFigureAt(i).getLinesColor().equals(linesC))
+ ok = false;
+
+ genLineCB.setColor(ok ? linesC : genLineC);
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).isThicknessable())
+ ok = false;
+
+ if(!ok)
+ {
+ Float thickness = listSelected.getFigureAt(i-1).getThickness();
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).isThicknessable() && listSelected.getFigureAt(i).getThickness()!=thickness)
+ ok = false;
+
+ setThicknessFieldValue(ok ? thickness : genThickness);
+ }
+ else setThicknessFieldValue(genThickness);
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).canHaveShadow())
+ ok = false;
+
+ if(!ok)
+ {
+ boolean hasShadow = listSelected.getFigureAt(i-1).hasShadow();
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).canHaveShadow() && listSelected.getFigureAt(i).hasShadow()!=hasShadow)
+ ok = false;
+
+ shadowCheckBox.setSelected(ok ? hasShadow : genHasShadow);
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).hasShadow())
+ ok = false;
+
+ if(!ok)
+ {
+ Color shadC = listSelected.getFigureAt(i-1).getShadowColor();
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).hasShadow() && !listSelected.getFigureAt(i).getShadowColor().equals(shadC))
+ ok = false;
+
+ genShadowCB.setColor(ok ? shadC : genShadowC);
+ }
+ else
+ genShadowCB.setColor(genShadowC);
+ }
+ else
+ shadowCheckBox.setSelected(genHasShadow);
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).canBeFilled())
+ ok = false;
+
+ if(!ok)
+ {
+ int j = i-1;
+ boolean isFilled = listSelected.getFigureAt(j).isFilled();
+ String hatchS = listSelected.getFigureAt(j).getHatchingStyle();
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).canBeFilled() && listSelected.getFigureAt(i).isFilled()!=isFilled)
+ ok = false;
+
+ filledCheckBox.setSelected(ok ? isFilled : genIsFilled);
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).canBeFilled() &&
+ (listSelected.getFigureAt(i).hasGradient() || listSelected.getFigureAt(i).isHatched()) &&
+ !listSelected.getFigureAt(i).getHatchingStyle().equals(hatchS))
+ ok = false;
+
+ setHatchChoice(ok ? hatchS : genHatchS);
+
+ if(ok)
+ if(listSelected.getFigureAt(j).hasGradient())
+ {
+ Color gradEndC = listSelected.getFigureAt(j).getGradientEndColor();
+ Color gradStartC = listSelected.getFigureAt(j).getGradientStartColor();
+ boolean okEnd = true;
+
+ for(i=0, ok=true; i<size; i++)
+ if(listSelected.getFigureAt(i).canBeHatched())
+ {
+ if(!listSelected.getFigureAt(i).getGradientEndColor().equals(gradEndC))
+ okEnd = false;
+ if(!listSelected.getFigureAt(i).getGradientStartColor().equals(gradStartC))
+ ok = false;
+ }
+
+ genGradientStartCB.setColor(ok ? gradStartC : genGradientStartC);
+ genGradientEndCB.setColor(okEnd ? gradEndC : genGradientEndC);
+ genHatchCB.setColor(genHatchC);
+ }
+ else
+ {
+ Color hatchC = listSelected.getFigureAt(j).getHatchingColor();
+
+ for(i=0, ok=true; i<size; i++)
+ if(listSelected.getFigureAt(i).canBeHatched() &&
+ !listSelected.getFigureAt(i).getHatchingColor().equals(hatchC))
+ ok = false;
+
+ genGradientStartCB.setColor(genGradientStartC);
+ genGradientEndCB.setColor(genGradientEndC);
+ genHatchCB.setColor(ok ? hatchC : genHatchC);
+ }
+ else
+ {
+ genGradientStartCB.setColor(genGradientStartC);
+ genGradientEndCB.setColor(genGradientEndC);
+ genHatchCB.setColor(genHatchC);
+ }
+
+ for(i=0, ok=true; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).isFilled())
+ ok = false;
+
+ if(!ok)
+ {
+ Color fillC = listSelected.getFigureAt(i-1).getInteriorColor();
+
+ for(ok=true, i=0; i<size && ok; i++)
+ if(listSelected.getFigureAt(i).isFilled() && !listSelected.getFigureAt(i).getInteriorColor().equals(fillC) &&
+ !listSelected.getFigureAt(i).hasGradient())
+ ok = false;
+
+ genInteriorCB.setColor(ok ? fillC : genInteriorC);
+ }
+ else genInteriorCB.setColor(genInteriorC);
+ }
+ else
+ {
+ genInteriorCB.setColor(genInteriorC);
+ setHatchChoice(genHatchS);
+ filledCheckBox.setSelected(genIsFilled);
+ buttonGradientStartC.setColor(genGradientStartC);
+ buttonGradientEndC.setColor(genGradientEndC);
+ buttonHatchColor.setColor(genHatchC);
+ }
+ }
+ else// In this case, the general values are used.
+ {
+ setBorderChoice(genBordPosS);
+ setLineChoice(genLineStyleS);
+ setDotChoice(genDotS);
+ dbleBoundCheckBox.setSelected(genHasDbleBord);
+ shadowCheckBox.setSelected(genHasShadow);
+ setHatchChoice(genHatchS);
+ filledCheckBox.setSelected(genIsFilled);
+ setLineArrowLChoice(genLeftArrS);
+ setLineArrowRChoice(genRightArrS);
+ setThicknessFieldValue(genThickness);
+ genDbleBordCB.setColor(genDbleC);
+ genGradientEndCB.setColor(genGradientEndC);
+ genGradientStartCB.setColor(genGradientStartC);
+ genInteriorCB.setColor(genInteriorC);
+ genLineCB.setColor(genLineC);
+ genHatchCB.setColor(genHatchC);
+ genShadowCB.setColor(genShadowC);
+ }
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(ex);
+ }
+ }
+
+
+
+
+
+ /**
+ * Allows to know if the user wants to auto adjust the
+ * borders of the drawing.
+ * @return True if the user wants it
+ */
+ public boolean isAutoAdjustBorders()
+ {
+ return getLMenuBar().getAutoAdjustBorders().isSelected();
+ }
+
+
+
+
+ /**
+ * Allows to know if the X-scale must be displayed
+ * @return True if the X-scale must be displayed
+ */
+ public boolean isXScaleDisplayed()
+ {
+ return getLMenuBar().getDisplayXScale().isSelected();
+ }
+
+
+
+ /**
+ * Allows to know if the Y-scale must be displayed
+ * @return True if the Y-scale must be displayed
+ */
+ public boolean isYScaleDisplayed()
+ {
+ return getLMenuBar().getDisplayYScale().isSelected();
+ }
+
+
+
+
+ /**
+ * Allows to know if the the borders of the drawing must be displayed
+ * @return True if the the borders of the drawing must be displayed
+ */
+ public boolean isBordersDisplayed()
+ {
+ return getLMenuBar().getDisplayBorders().isSelected();
+ }
+
+
+
+ /**
+ * Allows to know if the codePanel must be displayed
+ * @return True if the codePanel must be displayed
+ */
+ public boolean isCodePanelDisplayed()
+ {
+ if(codePanel==null)
+ return false;
+ return codePanel.isVisible();
+ }
+
+
+
+
+
+ public void actionPerformed(ActionEvent e)
+ {
+ Object src = e.getSource();
+
+ if(src instanceof JMenuItem || src instanceof JButton || src instanceof JToggleButton || src instanceof JCheckBox)
+ {
+ AbstractButton ab = ((AbstractButton)src);
+ String label = ab.getActionCommand();
+ Draw listSelected = drawPanel.getDraw().getSelected();
+ boolean ok = ab.isSelected();
+
+ try
+ {
+ if(label.equals(LaTeXDrawResources.LABEL_FILLED_CHECKBOX))
+ {
+ if(listSelected!=null && listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected!=null && listSelected.size()==1)
+ {
+ Figure selected = listSelected.getFigureAt(0);
+ selected.setIsFilled(ok && selected.canBeFilled());
+ buttonInteriorColor.setVisible(((ok && selected.canBeFilled()) || selected.hasShadow()));
+ buttonInteriorColor.setColor(selected.getInteriorColor());
+ }
+ else
+ {
+ genIsFilled = ok;
+
+ if(listSelected!=null)
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.canBeFilled())
+ f.setIsFilled(ok);
+ }
+
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ requestFocus();
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_DBLE_BOUND_CHECKBOX))
+ {
+ if(listSelected!=null && listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected!=null && listSelected.size()==1)
+ {
+ Figure selected = listSelected.getFigureAt(0);
+ selected.setHasDoubleBoundary(ok && selected.isDoubleBoundaryable());
+ buttonDbleBoundColor.setVisible(ok && selected.isDoubleBoundaryable());
+ }
+ else
+ {
+ genHasDbleBord = ok;
+
+ if(listSelected!=null)
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.isDoubleBoundaryable())
+ f.setHasDoubleBoundary(ok);
+ }
+
+ if(listSelected!=null) listSelected.updateBorders();
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ requestFocus();
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_SHADOW_CHECKBOX))
+ {
+ if(listSelected!=null && listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected!=null && listSelected.size()==1)
+ {
+ Figure selected = listSelected.getFigureAt(0);
+ selected.setHasShadow(ok && selected.canHaveShadow());
+ buttonShadowColor.setVisible(ok && selected.canHaveShadow());
+ buttonInteriorColor.setVisible((ok && selected.canHaveShadow() &&
+ selected.canBeFilled() && selected.shadowFillsShape() &&
+ !selected.hasGradient()) || (!ok && selected.isFilled()));
+ updateFillCB();
+ }
+ else
+ {
+ genHasShadow = ok;
+
+ if(listSelected!=null)
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.canHaveShadow())
+ f.setHasShadow(ok);
+ }
+
+ if(listSelected!=null) listSelected.updateBorders();
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ requestFocus();
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_ROTATE))
+ {
+ drawPanel.setOnRotation(!drawPanel.isOnRotation());
+ rotateButton.setSelected(drawPanel.isOnRotation());
+ drawPanel.
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_MAGNETIC_CB))
+ {
+ drawPanel.setGridIsMagnetic(toolbar.getMagneticCB().isSelected());
+ requestFocus();
+ return ;
+ }
+
+ if(label.compareTo(LaTeXDrawResources.LABEL_COLOR_HATCH)==0)
+ {
+ if(listSelected==null)
+ return ;
+
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.34"), buttonHatchColor.getColor()); //$NON-NLS-1$
+
+ if(c!=null)
+ {
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ {
+ buttonHatchColor.setColor(c);
+ listSelected.getFigureAt(0).setHatchingColor(c);
+ }
+ else
+ {
+ genHatchCB.setColor(c);
+ genHatchC = c;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.canBeHatched())
+ f.setHatchingColor(c);
+ }
+
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ }
+ requestFocus();
+ return ;
+ }
+
+ if(label.compareTo(LaTeXDrawResources.LABEL_COLOR_GRADIENT_FIRST)==0)
+ {
+ if(listSelected==null)
+ return ;
+
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getString1_7("LaTeXDrawFrame.7"), buttonGradientStartC.getColor()); //$NON-NLS-1$
+
+ if(c!=null)
+ {
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ {
+ buttonGradientStartC.setColor(c);
+ listSelected.getFigureAt(0).setGradientStartColor(c);
+ }
+ else
+ {
+ genGradientStartCB.setColor(c);
+ genGradientStartC = c;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.canBeHatched())
+ f.setGradientStartColor(c);
+ }
+
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ }
+
+ requestFocus();
+ return ;
+ }
+
+ if(label.compareTo(LaTeXDrawResources.LABEL_COLOR_GRADIENT_SECOND)==0)
+ {
+ if(listSelected==null)
+ return ;
+
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getString1_7("LaTeXDrawFrame.8"), buttonGradientEndC.getColor()); //$NON-NLS-1$
+
+ if(c!=null)
+ {
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ {
+ buttonGradientEndC.setColor(c);
+ listSelected.getFigureAt(0).setGradientEndColor(c);
+ }
+ else
+ {
+ genGradientEndCB.setColor(c);
+ genGradientEndC = c;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.canBeHatched())
+ f.setGradientEndColor(c);
+ }
+
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ }
+
+ requestFocus();
+ return ;
+ }
+
+ if(label.compareTo(LaTeXDrawResources.LABEL_COLOR_DBLE_BOUND)==0)
+ {
+ if(listSelected==null)
+ return ;
+
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.151"), buttonDbleBoundColor.getColor()); //$NON-NLS-1$
+
+ if(c!=null)
+ {
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ {
+ buttonDbleBoundColor.setColor(c);
+ Figure selected = listSelected.getFigureAt(0);
+ selected.setDoubleColor(c);
+ }
+ else
+ {
+ genDbleBordCB.setColor(c);
+ genDbleC = c;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.isDoubleBoundaryable())
+ f.setDoubleColor(c);
+ }
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ }
+
+ requestFocus();
+ return ;
+ }
+
+ if(label.compareTo(LaTeXDrawResources.LABEL_COLOR_SHADOW)==0)
+ {
+ if(listSelected==null)
+ return ;
+
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getString1_7("LaTeXDrawFrame.9"), buttonShadowColor.getColor()); //$NON-NLS-1$
+
+ if(c!=null)
+ {
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ {
+ buttonShadowColor.setColor(c);
+ listSelected.getFigureAt(0).setShadowColor(c);
+ }
+ else
+ {
+ genShadowCB.setColor(c);
+ genShadowC = c;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.canHaveShadow())
+ f.setShadowColor(c);
+ }
+
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ }
+ requestFocus();
+ return ;
+ }
+
+ if(label.compareTo(LaTeXDrawResources.LABEL_COLOR_BUTTON)==0)
+ {
+ if(listSelected==null)
+ return ;
+
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.36"), ((ColorButton)src).getColor()); //$NON-NLS-1$
+
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(c!=null)
+ {
+ if(listSelected.size()==1)
+ listSelected.getFigureAt(0).setLinesColor(c);
+ else
+ {
+ genLineC = c;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable())
+ f.setLinesColor(c);
+ }
+
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ ((ColorButton)src).setColor(c);
+ }
+
+ requestFocus();
+ return ;
+ }
+
+
+ if(label.compareTo(LaTeXDrawResources.LABEL_COLOR_INTERIOR_BUTTON)==0)
+ {
+ if(listSelected==null)
+ return ;
+
+ Color c = JColorChooser.showDialog((Component) e.getSource(),
+ LaTeXDrawLang.getDialogFrameString("AbstractParametersFrame.37"), ((ColorButton)src).getColor()); //$NON-NLS-1$
+
+ if(c!=null)
+ {
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ listSelected.getFigureAt(0).setInteriorColor(c);
+ else
+ {
+ genInteriorC = c;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.canBeFilled())
+ f.setInteriorColor(c);
+ }
+
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ ((ColorButton)src).setColor(c);
+ }
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_JOIN))
+ {
+ drawPanel.joinSelection(undoManager);
+ updateUndoRedo();
+ setSelection(true);
+ setIsModified(true);
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.154")); //$NON-NLS-1$
+ requestFocus();
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_SEPARATE))
+ {
+ drawPanel.separateSelection(undoManager);
+ updateUndoRedo();
+ setSelection(true);
+ setIsModified(true);
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.155")); //$NON-NLS-1$
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_BEHIND_SEL))
+ {
+ setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
+ drawPanel.setOnWaitingClicDispositionBehind(true);
+ requestFocus();
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_FRONT_SEL))
+ {
+ setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
+ drawPanel.setOnWaitingClicDispositionFront(true);
+ requestFocus();
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_BACKGROUND))
+ {
+ drawPanel.selectedInBackground();
+ setIsModified(true);
+ requestFocus();
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_FOREGROUND))
+ {
+ drawPanel.selectedInForeground();
+ setIsModified(true);
+ requestFocus();
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_ROTATE_90))
+ {
+ drawPanel.draw.rotateSelection(Math.PI/2.);
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_ROTATE_180))
+ {
+ drawPanel.draw.rotateSelection(Math.PI);
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_ROTATE_270))
+ {
+ drawPanel.draw.rotateSelection(3*Math.PI/2.);
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_MIRROR_H))
+ {
+ drawPanel.draw.mirrorHorizontal();
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_MIRROR_V))
+ {
+ drawPanel.draw.mirrorVertical();
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_TEX_EDITOR))
+ {
+ String title = LaTeXDrawLang.getString1_8("LaTeXDrawFrame.19"); //$NON-NLS-1$
+
+ if(pathTexEditor==null || pathTexEditor.length()==0)
+ JOptionPane.showMessageDialog(this, LaTeXDrawLang.getString1_8("LaTeXDrawFrame.20"), //$NON-NLS-1$
+ title, JOptionPane.WARNING_MESSAGE);
+ else
+ try{Runtime.getRuntime().exec(pathTexEditor);}
+ catch(Exception ex)
+ {
+ JOptionPane.showMessageDialog(this,
+ "<html>"+LaTeXDrawLang.getString1_8("LaTeXDrawFrame.21")+"<br>"+//$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
+ LaTeXDrawLang.getString1_8("LaTeXDrawFrame.22")+"</html>", //$NON-NLS-1$//$NON-NLS-2$
+ title, JOptionPane.WARNING_MESSAGE);
+ }
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_TEMPLATE_UPDATE))
+ {
+ menuBar.getMenuTemplate().updateTemplates();
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.160")); //$NON-NLS-1$
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_COMMENTS))
+ {
+ addCommentsFrame.setVisible(true);
+ return;
+ }
+
+
+ if(label.equals(LaTeXDrawResources.LABEL_PREFERENCES))
+ {
+ if(!preferencesFrame.isVisible())
+ preferencesFrame.setVisible(true);
+
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_INSERT_CODE))
+ {
+ if(insertCodeFrame==null)
+ insertCodeFrame = new InsertPSTricksCodeFrame(this);
+
+ insertCodeFrame.setVisible(true);
+ requestFocus();
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_DRAW_PROPERTIES))
+ {
+ if(drawPropertiesFrame==null)
+ drawPropertiesFrame = new DrawPropertiesFrame(this);
+
+ drawPropertiesFrame.setVisible(true);
+ return ;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_HELP))
+ {
+ if(helpFrame==null)
+ createHelpFrame();
+
+ if(helpFrame!=null)
+ helpFrame.setVisible(true);
+
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_DISPLAY_GRID))
+ {
+ if(menuBar.getDisplayGrid().isSelected())
+ {
+ menuBar.getDisplayPersoGrid().setSelected(false);
+ toolbar.getPersoGridGapField().setEnabled(false);
+ }
+
+ displayGrid(menuBar.getDisplayGrid().isSelected(), menuBar.getDisplayGrid().isSelected());
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_DISPLAY_PERSO_GRID))
+ {
+ if(menuBar.getDisplayPersoGrid().isSelected())
+ {
+ menuBar.getDisplayGrid().setSelected(false);
+ toolbar.getPersoGridGapField().setEnabled(true);
+ }
+
+ displayGrid(menuBar.getDisplayPersoGrid().isSelected(), !menuBar.getDisplayPersoGrid().isSelected());
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_ABOUT))
+ {
+ if(aboutTeXDraw==null)
+ createAboutLaTeXDrawFrame();
+
+ aboutTeXDraw.setVisible(true);
+ return;
+ }
+
+ if(label.equals(LaTeXDrawResources.LABEL_DISPLAY_CODE_PANEL))
+ {
+ if(!(e.getSource() instanceof JCheckBoxMenuItem))
+ menuBar.getDisplayCodePanel().setSelected(!menuBar.getDisplayCodePanel().isSelected());
+
+ displayCodePanel(menuBar.getDisplayCodePanel().isSelected());
+ requestFocus();
+ return;
+ }
+
+ if(label.compareTo(LaTeXDrawResources.TEMPLATE_START_ACTION_CMD)>0)
+ {
+ String str = label.substring(LaTeXDrawResources.TEMPLATE_START_ACTION_CMD.length());
+ boolean fromShared = str.charAt(0)=='0' ? false : true;
+ String path;
+ String name = str.substring(1) + SVGFilter.SVG_EXTENSION;
+
+ if(fromShared)
+ path = LaTeXDrawPath.PATH_TEMPLATES_SHARED==null ? null : LaTeXDrawPath.PATH_TEMPLATES_SHARED+File.separator+name;
+ else
+ path = LaTeXDrawPath.PATH_TEMPLATES_DIR_USER+File.separator+name;
+
+ Draw template = SVGDocumentGenerator.toLatexdraw(new File(path), null, null);
+
+ if(template!=null)
+ {
+ template.setDrawFigures(true);
+ template.setSelected(false);
+
+ if(template.size()==0)
+ return ;
+
+ drawPanel.getDraw().addFigure(template.size()>1 ? template : template.getFigureAt(0), undoManager);
+ updateUndoRedo();
+ drawPanel.updateDraw(true);
+ }
+ else
+ {
+ JOptionPane.showMessageDialog(this,
+ "<html>"+LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.19")+"<br>"+LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.20")+"</html>",//$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.21"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
+ }
+ requestFocus();
+ return ;
+ }
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(ex);
+ }
+ } // if(src instanceof JMenuItem || src instanceof JButton)
+ }
+
+
+
+
+ /**
+ * To launch when the selected figures are transformed : add an undo.
+ * @param listSelected THe list of the selected figures.
+ * @since 1.9.1
+ */
+ private void addToUndoTransformation(Draw listSelected)
+ {
+ try
+ {
+ Object clone = listSelected.clone();
+ Vector<Figure> figures = drawPanel.draw.getFigures();
+ int i, size = listSelected.size();
+ int[] id = new int[size];
+
+ for(i=0; i<size; i++)
+ id[i] = figures.indexOf(listSelected.getFigureAt(i));
+
+ undoManager.add(UndoRedoManager.LABEL_TRANSFORM, id, clone, false);
+ updateUndoRedo();
+
+ }catch(CloneNotSupportedException e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+ }
+
+
+
+ /**
+ * Allows to print the draw
+ */
+ public void printDraw()
+ {
+ PrinterJob printJob = PrinterJob.getPrinterJob();
+ printJob.setPrintable(drawPanel.getDraw());
+
+ System.setProperty("sun.java2d.print.pipeline", "pdl");//$NON-NLS-1$ //$NON-NLS-2$
+
+ if (printJob.printDialog())
+ {
+ try
+ {
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.162")); //$NON-NLS-1$
+ printJob.print();
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.163")); //$NON-NLS-1$
+ }
+ catch(Exception e)
+ {
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.164")); //$NON-NLS-1$
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+ }
+ }
+
+
+
+
+ /**
+ * Allows to print the code generated.
+ */
+ public void printCode()
+ {
+ drawPanel.updateCode();
+
+ PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
+ DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
+ PrintService printService[] = PrintServiceLookup.lookupPrintServices(null, null);
+ PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
+
+ if(printService!=null && printService.length!=0)
+ {
+ if(defaultService==null)
+ defaultService = printService[0];
+
+ PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, null, pras);
+
+ if(service != null)
+ {
+ DocPrintJob job = service.createPrintJob();
+ Doc doc = new SimpleDoc(codePanel.getText().getBytes(), flavor, null);
+
+ try { job.print(doc, pras); }
+ catch(PrintException ex) { JOptionPane.showMessageDialog(this, LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.22")); } //$NON-NLS-1$
+ }
+ }
+ else
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.23")); //$NON-NLS-1$
+ }
+
+
+
+ /**
+ * Allows to export the selected figures as a template in a file.
+ */
+ public void exportAsTemplate()
+ {
+ int res;
+ String templateName = null;
+ boolean ok;
+ File file = null;
+
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.168")); //$NON-NLS-1$
+
+ try
+ {
+ do
+ {
+ templateName = JOptionPane.showInputDialog(this,
+ LaTeXDrawLang.getOthersString("DrawContainer.nameTemplate")); //$NON-NLS-1$
+
+ if(templateName==null || templateName.equals(""))//$NON-NLS-1$
+ ok = false;
+ else
+ {
+ file = new File(LaTeXDrawPath.PATH_TEMPLATES_DIR_USER + File.separator + templateName + SVGFilter.SVG_EXTENSION);
+
+ if(!file.exists())
+ ok = true;
+ else
+ {
+ res = JOptionPane.showConfirmDialog(this,
+ LaTeXDrawLang.getOthersString("DrawContainer.overwriteTemplate"), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.42"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
+
+ ok = res==JOptionPane.YES_OPTION ? true : false;
+ }
+ }
+ }while(!ok);
+
+ Draw selection = getDrawPanel().getDraw().getSelected();
+
+ if(file!=null)
+ SVGDocumentGenerator.exportAsSVG(file.getPath(), selection);
+ else
+ templateName = null;
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+
+ if(templateName!=null)
+ {
+ menuBar.getMenuTemplate().addItem(templateName);
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.169")); //$NON-NLS-1$
+ }
+ else
+ setStatusBarText("");//$NON-NLS-1$
+ }
+
+
+
+ /**
+ * Allows to insert several figures from PSTricks code into the current draw
+ * @param code The code to parse and to convert in figures
+ */
+ public void insertPSTricksCode(String code)
+ {
+ try
+ {
+ String code2 = code;
+
+ if(code2!=null && code2.length()!=0)
+ {
+ if(PSTricksParser.containsBeginPSPicture(code2)==0)
+ {
+ String eol = System.getProperty("line.separator"); //$NON-NLS-1$
+ code2 = "\\begin{pspicture}(10,10)"+eol+code2+eol+"\\end{pspicture}";//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if(progressbarPST==null)
+ progressbarPST = new PSTProgressBarManager(this);
+
+ progressbarPST.setCodeToParse(code2);
+ progressbarPST.startProgressBar();
+ }
+ }catch (Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+ }
+
+
+
+
+ /**
+ * Imports a TeXFile.
+ */
+ public void importPSTricksFile()
+ {
+ currentFile = null;
+ projectName = null;
+ setTitle();
+ try
+ {
+ if(fileChooserImport==null)
+ {
+ fileChooserImport = new PictureChooser(this, LaTeXDrawLang.getString1_6("LaTeXDrawFrame.16"), //$NON-NLS-1$
+ false, LaTeXDrawLang.getString1_6("LaTeXDrawFrame.17")); //$NON-NLS-1$
+
+ JFileChooser fileChooser = fileChooserImport.getFileChooser();
+ if(pathExport!=null)
+ fileChooser.setCurrentDirectory(new File(pathExport));
+ fileChooser.setApproveButtonText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.199")); //$NON-NLS-1$
+ fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ fileChooser.setAcceptAllFileFilterUsed(false);
+ fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ fileChooser.addChoosableFileFilter(new TeXFilter());
+ fileChooser.setFileHidingEnabled(true);
+ fileChooser.setApproveButtonText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.171")); //$NON-NLS-1$
+ fileChooser.setMultiSelectionEnabled(false);
+ }
+
+ File file = fileChooserImport.displayFrame();
+
+ if(file==null) return;
+
+ importPSTricksFile(file.getAbsolutePath());
+
+ }catch (Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+ }
+
+
+
+
+ /**
+ * Allows to import a TeXFile with the filename given.
+ */
+ public boolean importPSTricksFile(String path)
+ {
+ try
+ {
+ File file = new File(path);
+
+ if(!file.exists() || !file.canRead() || !file.isFile())
+ return false;
+
+ setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.15")); //$NON-NLS-1$
+
+ reinitializeButtons();
+ preferencesFrame.addRecentFile(file.getAbsolutePath());
+ menuBar.updateRecentFilesMenu();
+ setIsModified(false);
+ newProject();
+ undoManager = new UndoRedoManager(drawPanel.getDraw().getFigures(), drawPanel.getDraw(), this);
+ updateUndoRedo();
+
+ if(progressbarPST==null)
+ progressbarPST = new PSTProgressBarManager(this);
+
+ progressbarPST.setFileToParse(file);
+ progressbarPST.startProgressBar();
+
+ return true;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ return false;
+ }
+ }
+
+
+
+
+ /**
+ * Allows to export the pstricks code as a .tex file
+ */
+ public void exportAsPsTricks()
+ {
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.170")); //$NON-NLS-1$
+
+ if(fileChooserExport==null)
+ fileChooserExport = new ExportDialog(currentFile==null ? pathExport : currentFile.getPath());
+
+ fileChooserExport.removeChoosableFileFilter(fileChooserExport.getFileFilter());
+ fileChooserExport.setFileFilter(fileChooserExport.getAcceptAllFileFilter());
+ fileChooserExport.setFileFilter(new TeXFilter());
+ fileChooserExport.setDialogTitle(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.172")); //$NON-NLS-1$
+
+ int res = fileChooserExport.showSaveDialog(this);
+ File file = fileChooserExport.getSelectedFile();
+
+ if(res != JFileChooser.APPROVE_OPTION || file==null)
+ {
+ setStatusBarText("");//$NON-NLS-1$
+ return;
+ }
+
+ projectName = file.getName();
+ String ex = TeXFilter.TEX_EXTENSION;
+ int id = projectName.toLowerCase().indexOf(ex.toLowerCase());
+
+ if(id ==-1)
+ file = new File(file.getPath() + TeXFilter.TEX_EXTENSION);
+
+ if(file.exists())
+ {
+ int replace = JOptionPane.showConfirmDialog(this,
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.173"), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.174"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
+
+
+ if(replace == JOptionPane.NO_OPTION)
+ return; // The user doesn't want to replace the file
+ }
+
+ PrintWriter out=null;
+
+ try // We export the code
+ {
+ FileWriter fw = new FileWriter(file);
+ BufferedWriter bw = new BufferedWriter(fw);
+ out = new PrintWriter(bw);
+
+ drawPanel.updateCode();
+ out.println(codePanel.getText());
+ out.close();
+ bw.close();
+ fw.close();
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.175")); //$NON-NLS-1$
+ }
+ catch (Exception e)
+ {
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.176")); //$NON-NLS-1$
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+
+ if(out!=null)
+ out.close();
+ setTitle();
+ }
+
+
+
+
+ public void exportAsPicture(String format)
+ {
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.177")); //$NON-NLS-1$
+
+ if(fileChooserExport==null)
+ fileChooserExport = new ExportDialog(currentFile==null ? pathExport : currentFile.getPath());
+
+ fileChooserExport.removeChoosableFileFilter(fileChooserExport.getFileFilter());
+ fileChooserExport.setFileFilter(fileChooserExport.getAcceptAllFileFilter());
+
+ if(format.equals(LaTeXDrawResources.LABEL_EXPORT_EPS))
+ fileChooserExport.setFileFilter(new EPSFilter());
+ else
+ if(format.equals(LaTeXDrawResources.LABEL_EXPORT_JPG))
+ fileChooserExport.setFileFilter(new JPGFilter());
+ else
+ if(format.equals(LaTeXDrawResources.LABEL_EXPORT_PNG))
+ fileChooserExport.setFileFilter(new PNGFilter());
+ else
+ if(format.equals(LaTeXDrawResources.LABEL_EXPORT_BMP))
+ fileChooserExport.setFileFilter(new BMPFilter());
+ else
+ if(format.equals(LaTeXDrawResources.LABEL_EXPORT_PPM))
+ fileChooserExport.setFileFilter(new PPMFilter());
+ else
+ return ;
+
+ fileChooserExport.setDialogTitle(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.179")+format +LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.183")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ int response = fileChooserExport.showSaveDialog(this);
+ File file = fileChooserExport.getSelectedFile();
+
+ if(response != JFileChooser.APPROVE_OPTION || file==null)
+ return;
+
+ String name = file.getName(), ex;
+
+ if(format.equals(LaTeXDrawResources.LABEL_EXPORT_EPS))
+ ex = LaTeXDrawResources.EPS_EXTENSION;
+ else if(format.equals(LaTeXDrawResources.LABEL_EXPORT_JPG))
+ ex = LaTeXDrawResources.JPG_EXTENSION;
+ else if(format.equals(LaTeXDrawResources.LABEL_EXPORT_BMP))
+ ex = LaTeXDrawResources.BMP_EXTENSION;
+ else if(format.equals(LaTeXDrawResources.LABEL_EXPORT_PNG))
+ ex = LaTeXDrawResources.PNG_EXTENSION;
+ else
+ ex = LaTeXDrawResources.PPM_EXTENSION;
+
+ int id = name.toLowerCase().indexOf(ex.toLowerCase());
+
+ if(id ==-1)
+ file = new File(file.getPath() + ex);
+
+ if(file.exists())
+ {
+ int replace = JOptionPane.showConfirmDialog(this,
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.173"), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.182")+format+LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.183"), //$NON-NLS-1$ //$NON-NLS-2$
+ JOptionPane.YES_NO_OPTION);
+
+
+ if(replace == JOptionPane.NO_OPTION)
+ return; // The user doesn't want to replace the file
+ }
+
+
+ try
+ {
+ int compressionRate = fileChooserExport.getCompressionRate();
+ drawPanel.exportAsPicture(file, format, compressionRate==-1 ? ExportDialog.DEFAULT_COMPRESSION_RATE :
+ 1.f-compressionRate/100.f);
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.184")); //$NON-NLS-1$
+ }
+ catch(Exception e)
+ {
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.185")); //$NON-NLS-1$
+ e.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(e);
+ }
+ }
+
+
+
+
+ /**
+ * Shutdown procedure when run as an application.
+ */
+ protected void windowClosed()
+ {
+ System.exit(0);
+ }
+
+
+
+
+ public void stateChanged(ChangeEvent e)
+ {
+ Object src = e.getSource();
+ String name = ((Component)src).getName();
+
+ if(src instanceof JSpinner)
+ {
+ Draw selection = drawPanel.getDraw().getSelected();
+
+ if(name.equals(LaTeXDrawResources.NAME_THICKNESS_FIELD))
+ {
+ float thick = Float.valueOf(thicknessField.getValue().toString()).floatValue();
+
+ if(selection!=null && selection.size()==1)
+ selection.getFigureAt(0).setThickness(thick);
+ else
+ {
+ if(selection!=null)
+ for(Figure f : selection.getFigures())
+ if(f.isCustomizable() && f.isThicknessable())
+ f.setThickness(thick);
+
+ genThickness = thick;
+ }
+
+ if(selection!=null) selection.updateBorders();
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ thicknessField.requestFocus();
+
+ return;
+ }
+
+ if(name.equals(LaTeXDrawResources.NAME_DOT_SIZE_FIELD))
+ {
+ float size = Float.valueOf(dotSizeField.getValue().toString()).floatValue();
+
+ if(selection!=null && selection.size()==1 && selection.getFigureAt(0) instanceof Dot)
+ ((Dot)selection.getFigureAt(0)).setWidth(size);
+ else
+ {
+ if(selection!=null)
+ for(Figure f : selection.getFigures())
+ if(f instanceof Dot)
+ ((Dot)f).setWidth(size);
+
+ genDotSize = size;
+ }
+
+ if(selection!=null) selection.updateBorders();
+ drawPanel.updateDraw(true);
+ drawPanel.setIsModified(true);
+ dotSizeField.requestFocus();
+
+ return;
+ }
+
+ if(name.equals(LaTeXDrawResources.LABEL_PERSO_GRID_GAP_FIELD))
+ {
+ drawPanel.getDraw().setPersonalGridGap(Integer.valueOf(toolbar.getPersoGridGapField().getValue().toString()).intValue());
+ drawPanel.setIsModified(true);
+ return ;
+ }
+ return ;
+ }
+
+ if(src instanceof JSlider)
+ {
+ JSlider slider = (JSlider)src;
+
+ if(name.equals(LaTeXDrawResources.NAME_SLIDER_DELIMITOR))
+ {
+ Delimitor.setOpacity(slider.getValue());
+ drawPanel.draw.repaint();
+ return ;
+ }
+ return ;
+ }
+ }
+
+
+
+
+
+ /**
+ * Allows to save the current project in as an SVG picture.
+ */
+ public boolean save(boolean saveAs)
+ {
+ if(!saveAs && !drawPanel.isModified())
+ return true;
+
+ File file;
+ boolean addToRecent = false;
+
+ // If the user want to "save as" or if he hasn't ever
+ // save his project, we display a dialog box in order to select a file
+ if(saveAs || currentFile==null)
+ {
+ if(fileChooserSave==null)
+ {
+ fileChooserSave = new JFileChooser(pathOpen);
+ fileChooserSave.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ fileChooserSave.setDialogTitle(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.188"));//$NON-NLS-1$
+ fileChooserSave.addChoosableFileFilter(new SVGFilter());
+ fileChooserSave.setMultiSelectionEnabled(false);
+ }
+
+ int response = fileChooserSave.showSaveDialog(this);
+
+ if(response != JFileChooser.APPROVE_OPTION)
+ return false;
+
+ file = fileChooserSave.getSelectedFile();
+
+ if(file==null)
+ return false;
+
+ projectName = file.getName();
+ String ex = SVGFilter.SVG_EXTENSION;
+ int id = projectName.toLowerCase().indexOf(ex.toLowerCase());
+
+ if(id ==-1)
+ file = new File(file.getPath() + SVGFilter.SVG_EXTENSION);
+ else
+ projectName = projectName.substring(0, id);
+
+ if(file.exists())
+ {
+ int replace = JOptionPane.showConfirmDialog(this,
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.173"), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.188"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
+
+ if(replace == JOptionPane.NO_OPTION || replace == JOptionPane.CLOSED_OPTION)
+ {
+ projectName = null;
+
+ return false;
+ }
+ }
+
+ currentFile = file;
+ addToRecent = true;
+ }
+ else file = currentFile;
+
+
+ try
+ {
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.186")); //$NON-NLS-1$
+ SVGDocumentGenerator.exportAsSVG(file.getPath(), getDrawPanel().getDraw());
+ setTitle();
+
+ if(addToRecent)
+ {
+ preferencesFrame.addRecentFile(file.getAbsolutePath());
+ menuBar.updateRecentFilesMenu();
+ }
+
+ drawPanel.setIsModified(false);
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.191")); //$NON-NLS-1$
+ }catch(Exception e)
+ {
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.192"));//$NON-NLS-1$
+ e.printStackTrace();
+ JOptionPane.showMessageDialog(this,
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.193") +e.toString(), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.86"), JOptionPane.WARNING_MESSAGE);//$NON-NLS-1$
+ }
+
+ return true;
+ }
+
+
+
+
+ public void newProject()
+ {
+ try
+ {
+ if(drawPanel.isModified())
+ switch(JOptionPane.showConfirmDialog(this,
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.156"), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.110"), //$NON-NLS-1$
+ JOptionPane.YES_NO_CANCEL_OPTION))
+ {
+ case JOptionPane.YES_OPTION:
+ boolean saved = save(false);
+ if(!saved) return;
+ break;
+ case JOptionPane.NO_OPTION:
+ break;
+ case JOptionPane.CANCEL_OPTION:
+ return;
+ }
+
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.197")); //$NON-NLS-1$
+ projectName = null;
+ setTitle();
+ drawPanel.newProject();
+ undoManager = new UndoRedoManager(drawPanel.getDraw().getFigures(), drawPanel.getDraw(), this);
+ reinitializeButtons();
+ setSelection(false);
+ currentFile = null;
+ drawPanel.getDraw().setIsModified(false);
+ xScale.repaint();
+ yScale.repaint();
+ setExportAsMenu(false);
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.198")); //$NON-NLS-1$
+
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(ex);
+ }
+ }
+
+
+
+
+ /**
+ * Allows to load a saved project
+ */
+ public boolean open(String fileName, boolean withDialog)
+ {
+ File file;
+
+ if(fileName==null)
+ {
+ if(fileChooserOpen==null)
+ {
+ fileChooserOpen = new JFileChooser(pathOpen);
+ fileChooserOpen.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ fileChooserOpen.addChoosableFileFilter(new LaTeXDrawFilter());
+ fileChooserOpen.addChoosableFileFilter(new SVGFilter());
+ fileChooserOpen.setMultiSelectionEnabled(false);
+ fileChooserOpen.setDialogTitle(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.200")); //$NON-NLS-1$
+ }
+
+ int id = fileChooserOpen.showOpenDialog(this);
+
+ if(id != JFileChooser.APPROVE_OPTION)
+ return false;
+
+ file = fileChooserOpen.getSelectedFile();
+
+ if(file==null)
+ return false;
+ }
+ else
+ file = new File(fileName);
+
+ setIsModified(false);
+ newProject();
+ currentFile = file;
+ reinitializeButtons();
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.201")); //$NON-NLS-1$
+ projectName = file.getName();
+ setExportAsMenu(true);
+
+ String ext = projectName.endsWith(LaTeXDrawResources.PROJECT_EXTENSION) ? LaTeXDrawResources.PROJECT_EXTENSION : SVGFilter.SVG_EXTENSION;
+ int id = projectName.toLowerCase().indexOf(ext.toLowerCase());
+
+ if(id !=-1)
+ projectName = projectName.substring(0, id);
+
+ if(file.exists() && file.isFile() && file.canRead())
+ {
+ try
+ {
+ if(ext.equals(SVGFilter.SVG_EXTENSION))
+ {
+ if(progressbarSVG==null)
+ progressbarSVG = new SVGProgressBarManager(this);
+
+ progressbarSVG.setFileToParse(file);
+ progressbarSVG.startProgressBar();
+ }
+ else
+ {
+ ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
+ DrawContainer draw;
+
+ if(!LaTeXDrawResources.LABEL_APP.equals(in.readObject()))
+ new LaTeXDrawException(LaTeXDrawException.NOT_TEXDRAW_FILE);
+
+ versionOfFile = (String)in.readObject();
+ boolean autoUpd = in.readBoolean();
+ formerIsInAutoUpdate = in.readBoolean();
+ boolean displayB = in.readBoolean();
+ menuBar.getAutoAdjustBorders().setSelected(in.readBoolean());
+
+ if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.9.3")>=0) //$NON-NLS-1$
+ {
+ draw = new DrawContainer();
+ draw.open(in);
+ }
+ else
+ draw = (DrawContainer)in.readObject();
+
+ drawPanel.setDraw(draw);
+ draw = drawPanel.getDraw();
+ draw.isSelection(false);
+ toolbar.getSliderDelimitor().setValue(Delimitor.getOpacity());
+ menuBar.getDisplayBorders().setSelected(displayB);
+ draw.setParentPanel(drawPanel);
+ draw.setAutoAdjustement(menuBar.getAutoAdjustBorders().isSelected());
+ draw.displayBorders(displayB);
+ undoManager.setFigures(draw.getFigures());
+ setPreferredSize((Dimension)in.readObject());
+ Point location = (Point)in.readObject();
+ setLocation(new Point(Math.max(0, location.x), Math.max(0, location.y)));
+ splitPane.setDividerLocation(in.readInt());
+ displayCodePanel(in.readBoolean());
+ codePanel.setIsInAutoUpdate(autoUpd);
+ Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
+ formerDividerLocation=(int)(dim.width*0.7);
+ formerIsInAutoUpdate = !isCodePanelDisplayed();
+ toolbar.getButtonImageBorders().setSelected(menuBar.getDisplayBorders().isSelected());
+ drawPanel.setIsGridDisplay(in.readBoolean());
+ menuBar.getDisplayXScale().setSelected(in.readBoolean());
+ menuBar.getDisplayYScale().setSelected(in.readBoolean());
+ codePanel.setComments((String) in.readObject());
+
+ if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.6")>=0) //$NON-NLS-1$
+ {
+ codePanel.setLabel((String)in.readObject());
+ codePanel.setCaption((String)in.readObject());
+ codePanel.setPositionHoriToken((String)in.readObject());
+ codePanel.setPositionVertToken((String)in.readObject());
+ }
+
+ if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.8")>=0) //$NON-NLS-1$
+ {
+ drawPanel.setGridIsMagnetic(in.readBoolean());
+ toolbar.getMagneticCB().setSelected(drawPanel.isGridMagnetic());
+ boolean isClassicGrid = in.readBoolean();
+ menuBar.getDisplayGrid().setSelected(isClassicGrid && drawPanel.isGridDisplayed());
+ menuBar.getDisplayPersoGrid().setSelected(!isClassicGrid && drawPanel.isGridDisplayed());
+ toolbar.getPersoGridGapField().setEnabled(menuBar.getDisplayPersoGrid().isSelected());
+ drawPanel.draw.setClassicGridDrawn(isClassicGrid);
+ drawPanel.draw.setPersonalGridGap(in.readInt());
+ toolbar.getPersoGridGapField().setValue(drawPanel.draw.getPersonalGridGap());
+ }
+ else
+ {
+ menuBar.getDisplayGrid().setSelected(drawPanel.isGridDisplayed());
+ menuBar.getDisplayPersoGrid().setSelected(false);
+ toolbar.getPersoGridGapField().setEnabled(false);
+ }
+
+ if(LaTeXDrawFrame.getVersionOfFile().compareTo("1.9")>=0) //$NON-NLS-1$
+ {
+ Delimitor.setOpacity(in.readInt());
+ toolbar.getSliderDelimitor().setValue(Delimitor.getOpacity());
+ }
+
+ currentFile = new File(currentFile.getPath().substring(0,
+ currentFile.getPath().length()-LaTeXDrawResources.PROJECT_EXTENSION.length())+SVGFilter.SVG_EXTENSION);
+ drawPanel.updateDraw(true);
+ in.close();
+
+ setTitle();
+ undoManager = new UndoRedoManager(drawPanel.getDraw().getFigures(), drawPanel.getDraw(), this);
+ updateUndoRedo();
+ setSelection(false);
+ setIsModified(false);
+ preferencesFrame.addRecentFile(file.getAbsolutePath());
+ menuBar.updateRecentFilesMenu();
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.202")); //$NON-NLS-1$
+ }
+ }
+ catch(InvalidClassException ex)
+ {
+ currentFile = null;
+ setIsModified(false);
+
+ if(withDialog)
+ JOptionPane.showMessageDialog(this, LaTeXDrawLang.getString1_9("LaTeXDrawFrame.12"), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.86"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
+ return false;
+ }
+ catch(Exception ex)
+ {
+ setIsModified(false);
+ currentFile = null;
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.203")); //$NON-NLS-1$
+ ex.printStackTrace();
+
+ if(withDialog)
+ JOptionPane.showMessageDialog(this,
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.204") + ex.toString(), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.86"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
+ return false;
+ }
+ }
+ else
+ {
+ setIsModified(false);
+ currentFile = null;
+ setStatusBarText(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.203")); //$NON-NLS-1$
+
+ if(withDialog)
+ JOptionPane.showMessageDialog(this, LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.18"), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.86"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
+ return false;
+ }
+
+ return true;
+ }
+
+
+
+ /**
+ * Allows to create and display a dialog box which ask to
+ * the user if he wants to save his project or not
+ * @return JOptionPane.YES_OPTION or JOptionPane.NO_OPTION
+ */
+ private int dialogConfirmSave()
+ {
+ return (JOptionPane.showConfirmDialog(this,
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.156"), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.110"), JOptionPane.YES_NO_CANCEL_OPTION)); //$NON-NLS-1$
+ }
+
+
+
+
+ /**
+ * Allows to create the frame which contains to LaTeXDraw help
+ */
+ private void createHelpFrame()
+ {
+ try
+ {
+ JPanel pHelp = new JPanel(new BorderLayout());
+ final JEditorPane htmlPageEditor = new JEditorPane();
+ htmlPageEditor.setEditable(false);
+ URL helpURL = getClass().getResource("/help/index.html");//$NON-NLS-1$
+ htmlPageEditor.setPage(helpURL);
+ helpFrame = new JFrame();
+ Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
+
+ htmlPageEditor.addHyperlinkListener(new HyperlinkListener()
+ {
+ public void hyperlinkUpdate(HyperlinkEvent event)
+ {
+ if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
+ try { htmlPageEditor.setPage(event.getURL()); }
+ catch(IOException ioe)
+ {
+ ioe.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(ioe);
+ }
+ }
+ });
+
+ JScrollPane scrollPane = new JScrollPane (htmlPageEditor);
+ scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+
+ pHelp.add(scrollPane);
+ helpFrame.getContentPane().add(pHelp, BorderLayout.CENTER);
+
+ helpFrame.setSize(dim.width,dim.height);
+ helpFrame.setLocation(0, 0);
+ helpFrame.setResizable(true);
+ helpFrame.setTitle(LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.215")); //$NON-NLS-1$
+ helpFrame.setVisible(false);
+
+ helpFrame.setIconImage(Toolkit.getDefaultToolkit().getImage(
+ getClass().getClassLoader().getResource("res/help-browser.png")));//$NON-NLS-1$
+
+ }catch(Exception ex)
+ {
+ JOptionPane.showMessageDialog(this,
+ LaTeXDrawLang.getString1_9("LaTeXDrawFrame.13"), //$NON-NLS-1$
+ LaTeXDrawLang.getString1_9("LaTeXDrawFrame.14"), //$NON-NLS-1$
+ JOptionPane.WARNING_MESSAGE);
+ }
+
+ }
+
+
+
+
+
+ /**
+ * Allows to create the "About LaTeXDraw" box
+ */
+ private void createAboutLaTeXDrawFrame()
+ {
+ Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
+ aboutTeXDraw = new JFrame();
+ JTabbedPane tabbedPane = new JTabbedPane();
+ JPanel p2 = new JPanel(), panel = new JPanel();
+ JButton okB = new JButton(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.23")); //$NON-NLS-1$
+
+ aboutTeXDraw.setTitle(LaTeXDrawResources.LABEL_ABOUT);
+ aboutTeXDraw.setLocation(dim.width*1/4, dim.height*1/16);
+
+ Image i = Toolkit.getDefaultToolkit().getImage(
+ getClass().getClassLoader().getResource("res/LaTeXDrawSmall.png"));//$NON-NLS-1$
+ MediaTracker tracker=new MediaTracker(this);
+ tracker.addImage(i,0);
+ try { tracker.waitForID(0); }
+ catch(InterruptedException e) { e.printStackTrace(); }
+
+ p2.add(new DisplayCanvas(i));
+
+ try
+ {
+ JEditorPane editorPane = new JEditorPane();
+ editorPane.setEditable(false);
+ editorPane.setDragEnabled(true);
+
+ editorPane.setContentType("text/html");//$NON-NLS-1$
+ editorPane.setBackground(tabbedPane.getBackground());
+ editorPane.setText("<html><body><div style=\"text-align: center; \"><font size=\"-1\"><br>"+ //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.218")+"<br>"+//$NON-NLS-1$//$NON-NLS-2$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.219")+//$NON-NLS-1$
+ VERSION + " " + VERSION_STABILITY + LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.220") + ID_BUILD+"<br><br>"+//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ LaTeXDrawResources.LABEL_APP+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.221")+"<br>"+//$NON-NLS-1$//$NON-NLS-2$
+ "Copyright(c) 2005-2008 - Arnaud BLOUIN - arno_b at users.sourceforge.net<br><br>"+//$NON-NLS-1$
+ "http://latexdraw.sourceforge.net/<br></div></body></html>");//$NON-NLS-1$
+
+ tabbedPane.add(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.24"), new JScrollPane(editorPane)); //$NON-NLS-1$
+ }
+ catch(Exception e) { System.out.println("About tabular cannot be created."); } //$NON-NLS-1$
+
+ try
+ {
+ JEditorPane editorPane = new JEditorPane();
+ editorPane.setEditable(false);
+ editorPane.setDragEnabled(true);
+
+ editorPane.setContentType("text/html");//$NON-NLS-1$
+ editorPane.setBackground(tabbedPane.getBackground());
+ editorPane.setText("<html><body><div style=\"text-align: center; \"><font size=\"-1\"><br><br>"+ //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LFrame2.25")+"<br><br>"+ //$NON-NLS-1$//$NON-NLS-2$
+ LaTeXDrawLang.getString1_6("LaTeXDrawFrame.18")+"<br>"+//$NON-NLS-1$//$NON-NLS-2$
+ LaTeXDrawLang.getString1_6("LaTeXDrawFrame.19")+"<br>"+//$NON-NLS-1$//$NON-NLS-2$
+ "<br></font></div></body></html>");//$NON-NLS-1$
+
+ tabbedPane.add(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.25"), new JScrollPane(editorPane)); //$NON-NLS-1$
+ }
+ catch(Exception e) { System.out.println("Library tabular cannot be created."); } //$NON-NLS-1$
+
+ try
+ {
+ JEditorPane editorPane = new JEditorPane(getClass().getResource("/res/translators.txt"));//$NON-NLS-1$
+ editorPane.setEditable(false);
+ editorPane.setDragEnabled(true);
+ tabbedPane.add(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.26"), new JScrollPane(editorPane)); //$NON-NLS-1$
+ }
+ catch(Exception e) { System.out.println("Translators tabular cannot be created."); } //$NON-NLS-1$
+
+ try
+ {
+ JEditorPane editorPane = new JEditorPane(getClass().getResource("/release_note.txt"));//$NON-NLS-1$
+ editorPane.setEditable(false);
+ editorPane.setDragEnabled(true);
+ tabbedPane.add(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.27"), new JScrollPane(editorPane)); //$NON-NLS-1$
+ }
+ catch(Exception e) { System.out.println("Release note tabular cannot be created."); } //$NON-NLS-1$
+
+ try
+ {
+ JEditorPane editorPane = new JEditorPane(getClass().getResource("/license.txt"));//$NON-NLS-1$
+ editorPane.setEditable(false);
+ editorPane.setDragEnabled(true);
+ tabbedPane.add(LaTeXDrawLang.getString1_8("LaTeXDrawFrame.28"), new JScrollPane(editorPane)); //$NON-NLS-1$
+ }
+ catch(Exception e) { System.out.println("License tabular cannot be created."); } //$NON-NLS-1$
+
+ tabbedPane.setPreferredSize(new Dimension(490, 290));
+ p2.add(tabbedPane);
+
+ aboutTeXDraw.setIconImage(LaTeXDrawResources.aboutIcon.getImage());
+
+ okB.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ aboutTeXDraw.setVisible(false);
+ }
+ });
+ panel.add(okB);
+
+ aboutTeXDraw.getContentPane().setLayout(new BorderLayout());
+ aboutTeXDraw.getContentPane().add(p2, BorderLayout.CENTER);
+ aboutTeXDraw.getContentPane().add(panel, BorderLayout.SOUTH);
+
+ aboutTeXDraw.setSize(500, 620);
+ aboutTeXDraw.setResizable(false);
+ }
+
+
+
+ private void readObject(@SuppressWarnings("unused") ObjectInputStream ois)
+ {
+ /* Nothing to do. */
+ }
+
+
+
+ /**
+ * Actions to do when an item change.
+ */
+ public void itemStateChanged(ItemEvent e)
+ {
+ if(e.getSource() instanceof LaTeXDrawComboBox)
+ {
+ LaTeXDrawComboBox c = (LaTeXDrawComboBox)e.getSource();
+ String label = c.getName();
+
+ try
+ {
+ DrawContainer draw = drawPanel.getDraw();
+ Draw listSelected = draw.getSelected();
+
+ if(label.compareTo(Figure.LABEL_HATCH_CHOICE)==0)
+ {
+ String style = ((JLabel) hatchChoice.getSelectedItem()).getText();
+ Object item = e.getItem();
+
+ if(listSelected==null ||
+ (item instanceof JLabel && ((JLabel)item).getName().compareTo(style)!=0 && listSelected.size()<2))
+ return ;
+
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ {
+ Figure selected = listSelected.getFigureAt(0);
+ selected.setHatchingStyle(style);
+
+ if(style.compareTo(PSTricksConstants.TOKEN_FILL_GRADIENT)==0)
+ {
+ buttonGradientEndC.setVisible(true);
+ buttonGradientStartC.setVisible(true);
+ buttonInteriorColor.setVisible(false);
+ filledCheckBox.setVisible(false);
+ buttonHatchColor.setVisible(false);
+ }
+ else
+ {
+ buttonHatchColor.setVisible(style.compareTo(PSTricksConstants.TOKEN_FILL_SOLID)!=0 &&
+ style.compareTo(PSTricksConstants.TOKEN_FILL_NONE)!=0);
+ filledCheckBox.setVisible(true);
+ buttonGradientEndC.setVisible(false);
+ buttonGradientStartC.setVisible(false);
+ buttonInteriorColor.setVisible(filledCheckBox.isSelected());
+ }
+ }
+ else
+ {
+ genHatchS = style;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.canBeHatched())
+ f.setHatchingStyle(style);
+ }
+
+ updateFillCB();
+ drawPanel.updateDraw(true);
+ setIsModified(true);
+ return ;
+ }
+
+ if(label.compareTo(Figure.LABEL_BORDERS_POSITION_CHOICE)==0)
+ {
+ String style = ((JLabel) bordersPositionChoice.getSelectedItem()).getText();
+ Object item = e.getItem();
+
+ if(listSelected==null ||
+ (item instanceof JLabel && ((JLabel)item).getName().compareTo(style)!=0 && listSelected.size()<2))
+ return ;
+
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ listSelected.getFigureAt(0).setBordersPosition(style);
+ else
+ {
+ genBordPosS = style;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.isBordersMovable())
+ f.setBordersPosition(style);
+ }
+
+ listSelected.updateBorders();
+ drawPanel.updateDraw(true);
+ setIsModified(true);
+ return ;
+ }
+
+ if(label.compareTo(LaTeXDrawResources.CHOICE_ARROW_LEFT_NAME)==0)
+ {
+ String arrowS = ((JLabel)lineArrowLChoice.getSelectedItem()).getText();
+ Object item = e.getItem();
+
+ if(listSelected==null ||
+ (item instanceof JLabel && ((JLabel)item).getName().compareTo(arrowS)!=0 && listSelected.size()<2))
+ return ;
+
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ {
+ Figure selected = listSelected.getFigureAt(0);
+
+ if(selected instanceof Arrowable)
+ ((Arrowable)selected).setArrow1Style(arrowS);
+ }
+ else
+ {
+ genLeftArrS = arrowS;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f instanceof Arrowable)
+ ((Arrowable)f).setArrow1Style(arrowS);
+ }
+
+ drawPanel.updateDraw(true);
+ setIsModified(true);
+ return;
+ }
+
+ if(label.compareTo(LaTeXDrawResources.CHOICE_ARROW_RIGHT_NAME)==0)
+ {
+ String arrowS = ((JLabel)lineArrowRChoice.getSelectedItem()).getText();
+ Object item = e.getItem();
+
+ if(listSelected==null ||
+ (item instanceof JLabel && ((JLabel)item).getName().compareTo(arrowS)!=0 && listSelected.size()<2))
+ return ;
+
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ {
+ Figure selected = listSelected.getFigureAt(0);
+
+ if(selected instanceof Arrowable)
+ {
+ if(((Arrowable)selected).hasTwoLeftArrows())
+ arrowS = ArrowHead.invertArrowStyle(arrowS);
+
+ ((Arrowable)selected).setArrow2Style(arrowS);
+ }
+ }
+ else
+ {
+ genRightArrS = arrowS;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f instanceof Arrowable)
+ ((Arrowable)f).setArrow2Style(((Arrowable)f).hasTwoLeftArrows() ?
+ ArrowHead.invertArrowStyle(arrowS) : arrowS);
+ }
+
+ drawPanel.updateDraw(true);
+ setIsModified(true);
+ return;
+ }
+
+
+ if(label.compareTo(LaTeXDrawResources.CHOICE_LINE_NAME)==0)
+ {
+ String str = ((JLabel) lineChoice.getSelectedItem()).getText();
+ Object item = e.getItem();
+
+ if(listSelected==null ||
+ (item instanceof JLabel && ((JLabel)item).getName().compareTo(str)!=0 && listSelected.size()<2))
+ return ;
+
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ listSelected.getFigureAt(0).setLineStyle(str);
+ else
+ {
+ genLineStyleS = str;
+
+ for(Figure f : listSelected.getFigures())
+ if(f.isCustomizable() && f.isDashableOrDotable())
+ f.setLineStyle(str);
+ }
+
+ drawPanel.updateDraw(true);
+ setIsModified(true);
+ return ;
+ }
+
+
+ if(label.compareTo(LaTeXDrawResources.CHOICE_DOT_NAME)==0)
+ {
+ String str = ((JLabel) dotChoice.getSelectedItem()).getText();
+ Object item = e.getItem();
+
+ if(listSelected==null ||
+ (item instanceof JLabel && ((JLabel)item).getName().compareTo(str)!=0 && listSelected.size()<2))
+ return ;
+
+ if(listSelected.size()>0)
+ addToUndoTransformation(listSelected);
+
+ if(listSelected.size()==1)
+ {
+ Figure selected = listSelected.getFigureAt(0);
+
+ if(selected instanceof Dot)
+ {
+ ((Dot)selected).setCurrentStyle(str);
+ filledCheckBox.setVisible(false);
+ buttonInteriorColor.setVisible(((Dot)selected).canBeFilled() && selected.isFilled());
+ }
+ }
+ else
+ {
+ genDotS = str;
+
+ for(Figure f : listSelected.getFigures())
+ if(f instanceof Dot)
+ ((Dot)f).setCurrentStyle(str);
+ }
+
+ listSelected.updateBorders();
+ setIsModified(true);
+ drawPanel.updateDraw(true);
+ return;
+ }
+
+ }catch(Exception ex)
+ {
+ ex.printStackTrace();
+ ExceptionFrameDialog.showExceptionDialog(ex);
+ }
+ }
+ }
+
+
+
+ /**
+ * @return Returns the xScale.
+ */
+ public XScale getXScale()
+ {
+ return xScale;
+ }
+
+
+
+
+ /**
+ * @return Returns the yScale.
+ */
+ public YScale getYScale()
+ {
+ return yScale;
+ }
+
+
+
+
+ /**
+ * @return the checkNewVersion
+ */
+ public boolean isCheckNewVersion()
+ {
+ return checkNewVersion;
+ }
+
+
+
+
+ /**
+ * @param checkNewVersion the checkNewVersion to set
+ */
+ public void setCheckNewVersion(boolean checkNewVersion)
+ {
+ this.checkNewVersion = checkNewVersion;
+ }
+
+
+
+
+ /**
+ * @return the text of statusBar
+ */
+ public String getStatusBarText()
+ {
+ return statusBar.getText();
+ }
+
+
+
+
+ /**
+ * @param text The text to put in the statusbar
+ */
+ public void setStatusBarText(String text)
+ {
+ statusBar.setText(text);
+ }
+
+
+
+
+ /**
+ * @param unitForPixelsPerCm The unitForPixelsPerCm to set.
+ */
+ public void setUnitForPixelsPerCm(String unitForPixelsPerCm)
+ {
+ drawPanel.getDraw().setUnitForPixelsPerCm(unitForPixelsPerCm);
+ xScale.setUnitForPixelsPerCm(unitForPixelsPerCm);
+ }
+
+
+
+
+ /**
+ * Allows to choose and to insert a picture in the draw
+ */
+ public void insertPicture()
+ {
+ try
+ {
+ if(fileChooserPicture==null)
+ fileChooserPicture = new PictureChooser(this, LaTeXDrawLang.getString1_6("LaTeXDrawFrame.23"), //$NON-NLS-1$
+ true, LaTeXDrawLang.getString1_6("LaTeXDrawFrame.1")); //$NON-NLS-1$
+
+ File file = fileChooserPicture.displayFrame();
+
+ if(file!=null && file.canRead() && file.isFile())
+ {
+ setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.25")); //$NON-NLS-1$
+
+ boolean state = drawPanel.insertPicture(undoManager, file.getAbsolutePath());
+ if(state) setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.28")); //$NON-NLS-1$
+ else setStatusBarText(LaTeXDrawLang.getString1_6("LaTeXDrawFrame.27")); //$NON-NLS-1$
+ }
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ JOptionPane.showMessageDialog(this,
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.204") + ex.toString(), //$NON-NLS-1$
+ LaTeXDrawLang.getStringLaTeXDrawFrame("LaTeXDrawFrame.86"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
+ }
+ }
+
+
+
+
+ /**
+ * Allows to convert several figures in an other format.
+ */
+ public void batchConvertion()
+ {
+ convertFrame.setVisible(true);
+ }
+
+
+
+
+ /**
+ * @param state Define if the grid must be magnetic.
+ */
+ public void setMagneticGrid(boolean state)
+ {
+ toolbar.getMagneticCB().setSelected(state);
+ drawPanel.setGridIsMagnetic(state);
+ }
+
+
+
+
+ /**
+ * @param value Define the interval between two lines of the personal grid.
+ */
+ public void setPersoGridGap(int value)
+ {
+ toolbar.getPersoGridGapField().setValue(value);
+ drawPanel.draw.setPersonalGridGap(value);
+ }
+
+
+
+
+
+ /**
+ * @return the pathTexEditor.
+ */
+ public String getPathTexEditor()
+ {
+ return pathTexEditor;
+ }
+
+
+
+
+ /**
+ * @param pathTexEditor the pathTexEditor to set.
+ */
+ public void setPathTexEditor(String pathTexEditor)
+ {
+ this.pathTexEditor = pathTexEditor;
+ }
+
+
+
+ /**
+ * Selects all the figures of the current drawing and put the current action to "selection".
+ * @since 1.9
+ */
+ public void selectAllFigures()
+ {
+ menuBar.getMenuSelect().setSelected(true);
+ toolbar.getButtonImageSelect().setSelected(true);
+ actionPerformed(new ActionEvent(menuBar.getMenuSelect(), 0, LaTeXDrawResources.LABEL_SELECT_FIGURE));
+ drawPanel.getDraw().selectAll();
+ setSelection(true);
+ setCurrentChoice(LaTeXDrawResources.LABEL_SELECT_FIGURE);
+ }
+
+
+
+
+ public void showShortcutsFrame()
+ {
+ if(shortcutsFrame==null)
+ shortcutsFrame = new ShortcutsFrame();
+
+ shortcutsFrame.setVisible(true);
+ }
+
+
+
+
+ public static void setCurrentChoice(String currentChoice)
+ {
+ LaTeXDrawFrame.currentChoice = currentChoice;
+ }
+
+
+
+
+ public void setFormerIsInAutoUpdate(boolean formerIsInAutoUpdate)
+ {
+ this.formerIsInAutoUpdate = formerIsInAutoUpdate;
+ }
+
+
+
+
+ /**
+ * @return the lookAndFeel.
+ * @since 1.9
+ */
+ public static String getLookAndFeel()
+ {
+ return lookAndFeel;
+ }
+
+
+
+
+ /**
+ * @param lookAndFeel the lookAndFeel to set.
+ * @since 1.9
+ */
+ public static void setLookAndFeel(String lookAndFeel)
+ {
+ if(lookAndFeel==null)
+ throw new IllegalArgumentException();
+
+ LaTeXDrawFrame.lookAndFeel = lookAndFeel;
+ }
+
+
+ /**
+ * @return True if the selection of figures is activated.
+ * @since 1.9
+ */
+ public boolean isOnSelection()
+ {
+ return getLMenuBar().getMenuSelect().isSelected();
+ }
+
+
+
+
+ /**
+ * Defines if the CheckBox FillCB must be enable or not considering if the current selected figure.
+ * has a shadow or not (in pstricks, all shape having a shadow is filled but joined-lines, akin-points and Bézier curves).
+ * @since 1.9
+ */
+ protected void updateFillCB()
+ {
+ Draw selection = drawPanel.draw.getSelected();
+
+ if(selection!=null && selection.size()==1)
+ {
+ Figure f = selection.getFigureAt(0);
+
+ if(!f.canBeFilled())
+ return ;
+
+ if(f instanceof JoinedLines || f instanceof BezierCurve || f instanceof AkinPoints)
+ {
+ String txt = f.getHatchingStyle();
+
+ filledCheckBox.setEnabled(!(shadowCheckBox.isSelected() && f.canHaveShadow() &&
+ (txt.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_CROSSHATCH_F) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_HLINES) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_HLINES_F) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_VLINES) ||
+ txt.equals(PSTricksConstants.TOKEN_FILL_VLINES_F))));
+ }
+ else
+ filledCheckBox.setEnabled(!shadowCheckBox.isSelected() || !f.canHaveShadow());
+ }
+ }
+
+
+
+
+ /**
+ * Initialise the values of the general parameters (do not change the fields).
+ * @since 1.9.1
+ */
+ protected void initializeGeneralFields()
+ {
+ genBordPosS = Figure.DEFAULT_BORDERS_POSITION;
+ genDbleBordCB.setColor(Figure.DEFAULT_DOUBLE_COLOR);
+ genDotS = Dot.DEFAULT_DOT_STYLE;
+ genGradientEndCB.setColor(PSTricksConstants.DEFAULT_GRADIENT_END_COLOR);
+ genGradientStartCB.setColor(PSTricksConstants.DEFAULT_GRADIENT_START_COLOR);
+ genHasDbleBord = Figure.DEFAULT_HAS_DOUBLE_BOUNDARY;
+ genHatchCB.setColor(Figure.DEFAULT_HATCH_COL);
+ genHatchS = Figure.DEFAULT_HATCH_STYLE;
+ genInteriorCB.setColor(Figure.DEFAULT_INTERIOR_COL);
+ genIsFilled = Figure.DEFAULT_IS_FILLED;
+ genLeftArrS = genRightArrS = ArrowHead.DEFAULT_STYLE;
+ genLineCB.setColor(Figure.DEFAULT_BORDERS_COL);
+ genLineStyleS = Figure.DEFAULT_LINE_STYLE;
+ genThickness = Figure.DEFAULT_THICKNESS;
+ genDotSize = Dot.DEFAULT_WIDTH;
+ genGradientEndC = PSTricksConstants.DEFAULT_GRADIENT_END_COLOR;
+ genGradientStartC = PSTricksConstants.DEFAULT_GRADIENT_START_COLOR;
+ genDbleC = Figure.DEFAULT_DOUBLE_COLOR;
+ genHatchC = Figure.DEFAULT_HATCH_COL;
+ genInteriorC = Figure.DEFAULT_INTERIOR_COL;
+ genLineC = Figure.DEFAULT_BORDERS_COL;
+ genShadowC = Figure.DEFAULT_SHADOW_COLOR;
+ }
+
+
+
+ /**
+ * @return The frame of preferences.
+ * @since 2.0.0
+ */
+ public PreferencesFrame getPreferencesFrame()
+ {
+ return preferencesFrame;
+ }
+
+
+
+ public void windowStateChanged(WindowEvent e)
+ {
+ updateSplitSeparatorPosition();
+ }
+
+
+
+ /**
+ * Update the position of the divider.
+ * @since 2.0.0
+ */
+ public void updateSplitSeparatorPosition()
+ {
+ if(isCodePanelDisplayed())
+ {
+ int widthFrame, dividerLocation;
+
+ formerDividerLocation = splitPane.getDividerLocation();
+ widthFrame = getExtendedState()==Frame.MAXIMIZED_BOTH ? Toolkit.getDefaultToolkit().getScreenSize().width : getSize().width;
+ dividerLocation = (int)(widthFrame*getDividerPosition());
+ splitPane.setDividerLocation(dividerLocation);
+ codePanel.editor.setPreferredSize(new Dimension(widthFrame-dividerLocation, codePanel.editor.getPreferredSize().height));
+ codePanel.editor.revalidate();
+ }
+ }
+
+
+
+ /**
+ * @return the splitPane.
+ * @since 2.0.0
+ */
+ public JSplitPane getSplitPane()
+ {
+ return splitPane;
+ }
+
+
+
+
+ public double getDividerCurrentLocation()
+ {
+ return isCodePanelDisplayed() ? splitPane.getDividerLocation() : formerDividerLocation;
+ }
+
+
+
+ /**
+ * @return the dividerPosition read in the preferences file.
+ * @since 2.0.0
+ */
+ public double getDividerPosition()
+ {
+ return dividerPosition;
+ }
+
+
+
+ /**
+ * @param dividerPosition the dividerPosition to set in ]0;1[.
+ * @since 2.0.0
+ */
+ public void setDividerPosition(double dividerPosition)
+ {
+ if(dividerPosition>0 && dividerPosition<=1)
+ {
+ this.dividerPosition = dividerPosition;
+ updateSplitSeparatorPosition();
+ }
+ }
+
+
+
+
+ /**
+ * Sets the XML element "meta" with the parameters of the code panel.
+ * @param document The XML document.
+ * @param meta The Element to fill.
+ * @throws IllegalArgumentException If document or meta is null.
+ * @since 2.0.0
+ */
+ public void getXMLMetadata(Document document, Element meta)
+ {
+ if(document==null || meta==null)
+ throw new IllegalArgumentException();
+
+ Element elt = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_VERSION), elt2;
+
+ elt.appendChild(document.createTextNode(VERSION));
+ meta.appendChild(elt);
+
+ elt = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_SIZE);
+ meta.appendChild(elt);
+
+ elt2 = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_WIDTH);
+ elt2.setTextContent(String.valueOf(getWidth()));
+ elt.appendChild(elt2);
+
+ elt2 = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_HEIGHT);
+ elt2.setTextContent(String.valueOf(getHeight()));
+ elt.appendChild(elt2);
+
+ elt = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_POSITION);
+ meta.appendChild(elt);
+
+ elt2 = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_POSITION_X);
+ elt2.setTextContent(String.valueOf(getLocation().x));
+ elt.appendChild(elt2);
+
+ elt2 = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_POSITION_Y);
+ elt2.setTextContent(String.valueOf(getLocation().y));
+ elt.appendChild(elt2);
+
+ elt = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_DIVIDER_POSITION);
+ double divLoc = isCodePanelDisplayed() ? getDividerCurrentLocation() : 1;
+ elt.setTextContent(String.valueOf(divLoc<getWidth() && divLoc>1 ? divLoc/getWidth() : 0.8));
+ meta.appendChild(elt);
+
+ elt = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_DISPLAY_CODE_PANEL);
+ elt.setTextContent(String.valueOf(menuBar.getDisplayCodePanel().isSelected()));
+ meta.appendChild(elt);
+
+ elt = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_DISPLAY_X);
+ elt.setTextContent(String.valueOf(menuBar.getDisplayXScale().isSelected()));
+ meta.appendChild(elt);
+
+ elt = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_DISPLAY_Y);
+ elt.setTextContent(String.valueOf(menuBar.getDisplayYScale().isSelected()));
+ meta.appendChild(elt);
+
+ elt = document.createElement(LaTeXDrawNamespace.LATEXDRAW_NAMESPACE+':'+LaTeXDrawNamespace.XML_DELIMITOR_OPACITY);
+ elt.setTextContent(String.valueOf(Delimitor.getOpacity()));
+ meta.appendChild(elt);
+ }
+
+
+
+ /**
+ * Sets the latexdraw parameters from the <code>metadata</code> SVG tag.
+ * @param nl The list of the parameters.
+ * @since 2.0.0
+ */
+ public void setXMLMetadata(NodeList nl)
+ {
+ if(nl==null)
+ return ;
+
+ Node n, n2;
+ String name;
+ double dividerPos = -1;
+
+ for(int i=0, size = nl.getLength(); i<size; i++)
+ {
+ n = nl.item(i);
+
+ if(n!=null && LaTeXDrawNamespace.LATEXDRAW_NAMESPACE_URI.equals(n.getNamespaceURI()))
+ {
+ name = n.getNodeName();
+
+ try
+ {
+ if(name.endsWith(LaTeXDrawNamespace.XML_SIZE))
+ {
+ NodeList nl2 = n.getChildNodes();
+
+ for(int j=0, size2 = nl2.getLength(); j<size2; j++)
+ {
+ n2 = nl2.item(j);
+
+ if(n2.getNodeName().endsWith(LaTeXDrawNamespace.XML_WIDTH))
+ setSize(Double.valueOf(n2.getTextContent()).intValue(), getHeight());
+ else
+ if(n2.getNodeName().endsWith(LaTeXDrawNamespace.XML_HEIGHT))
+ setSize(getWidth(), Double.valueOf(n2.getTextContent()).intValue());
+ }
+ }
+ else if(name.endsWith(LaTeXDrawNamespace.XML_POSITION))
+ {
+ NodeList nl2 = n.getChildNodes();
+
+ for(int j=0, size2 = nl2.getLength(); j<size2; j++)
+ {
+ n2 = nl2.item(j);
+
+ if(n2.getNodeName().endsWith(LaTeXDrawNamespace.XML_POSITION_X))
+ setLocation(Math.max(0, Double.valueOf(n2.getTextContent()).intValue()), getLocation().y);
+ else
+ if(n2.getNodeName().endsWith(LaTeXDrawNamespace.XML_POSITION_Y))
+ setLocation(getLocation().x, Math.max(0, Double.valueOf(n2.getTextContent()).intValue()));
+ }
+ }
+ else if(name.endsWith(LaTeXDrawNamespace.XML_DIVIDER_POSITION))
+ dividerPos = Double.valueOf(n.getTextContent()).doubleValue();
+ else if(name.endsWith(LaTeXDrawNamespace.XML_DISPLAY_CODE_PANEL))
+ displayCodePanel(Boolean.valueOf(n.getTextContent()).booleanValue());
+ else if(name.endsWith(LaTeXDrawNamespace.XML_DISPLAY_X))
+ displayXScale(Boolean.valueOf(n.getTextContent()).booleanValue());
+ else if(name.endsWith(LaTeXDrawNamespace.XML_DISPLAY_Y))
+ displayYScale(Boolean.valueOf(n.getTextContent()).booleanValue());
+ else if(name.endsWith(LaTeXDrawNamespace.XML_DELIMITOR_OPACITY))
+ Delimitor.setOpacity(Double.valueOf(n.getTextContent()).intValue());
+ }
+ catch(Exception e) { e.printStackTrace(); System.out.println(name + ": invalid value."); }//$NON-NLS-1$
+ }
+ }
+
+ if(dividerPos>0)
+ {
+ formerDividerLocation = (int)(getWidth()*dividerPos);
+ setDividerPosition(dividerPos);
+ }
+ }
+
+
+ /**
+ * @return The menu listener.
+ * @since 2.0.0
+ */
+ public MenusListener getMenuListener()
+ {
+ return menusListener;
+ }
+
+ /**
+ * @return the toolbar.
+ * @since 2.0.0
+ */
+ public LToolbar getToolbar()
+ {
+ return toolbar;
+ }
+
+
+ /**
+ * @return The recent files Listener.
+ * @since 2.0.0
+ */
+ public RecentFilesListener getRecentFilesListener()
+ {
+ return recentFilesListener;
+ }
+
+
+ public LMenuBar getLMenuBar()
+ {
+ return menuBar;
+ }
+
+
+ /**
+ * @return the progressBar.
+ * @since 2.0.0
+ */
+ public JProgressBar getProgressBar()
+ {
+ return progressBar;
+ }
+
+
+ /**
+ * @return the stopButton.
+ * @since 2.0.0
+ */
+ public JButton getStopButton()
+ {
+ return stopButton;
+ }
+
+
+
+ /**
+ * @return the currentFile.
+ * @since 2.0.0
+ */
+ public File getCurrentFile()
+ {
+ return currentFile;
+ }
+
+
+
+ /**
+ * @param currentFile the currentFile to set.
+ * @since 2.0.0
+ */
+ public void setCurrentFile(File currentFile)
+ {
+ this.currentFile = currentFile;
+ }
+
+
+ /**
+ * @return the formerDividerLocation.
+ * @since 2.0.0
+ */
+ public int getFormerDividerLocation()
+ {
+ return formerDividerLocation;
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/latexdraw.git
More information about the pkg-java-commits
mailing list