/*

 * Title: japlot.jaxodraw
 * Description: Graphical user interface for drawing Feynman diagrams
 * @author Daniele Binosi 
 * @author Lukas Theussl  

 Copyright (C) 2003-2006,  Daniele Binosi and Lukas Theussl

 See the file LICENSE in the source distribution home directory
 for a full copy of the GPL (GNU General Public License).

    This file is part of japlot.jaxodraw.

    japlot.jaxodraw 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.

    japlot.jaxodraw is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


 */
package japlot.jaxodraw;

import java.awt.Color;
import java.awt.Font;
import java.awt.GraphicsEnvironment;

import java.util.ResourceBundle;

import javax.swing.JOptionPane;

import jhplot.jadraw.JaBlob;
import jhplot.jadraw.JaBox;
import jhplot.jadraw.JaFArc;
import jhplot.jadraw.JaFLine;
import jhplot.jadraw.JaFLoop;
import jhplot.jadraw.JaGArc;
import jhplot.jadraw.JaGLine;
import jhplot.jadraw.JaGLoop;
import jhplot.jadraw.JaGlArc;
import jhplot.jadraw.JaGlLine;
import jhplot.jadraw.JaGlLoop;
import jhplot.jadraw.JaLatexText;
import jhplot.jadraw.JaObject;
import jhplot.jadraw.JaPArc;
import jhplot.jadraw.JaPLine;
import jhplot.jadraw.JaPLoop;
import jhplot.jadraw.JaText;
import jhplot.jadraw.JaSArc;
import jhplot.jadraw.JaSLine;
import jhplot.jadraw.JaSLoop;
import jhplot.jadraw.JaVertexT1;
import jhplot.jadraw.JaVertexT2;
import jhplot.jadraw.JaVertexT3;
import jhplot.jadraw.JaVertexT4;
import jhplot.jadraw.JaVertexT5;
import jhplot.jadraw.JaVertexT6;
import jhplot.jadraw.JaZigZagLine;


/** A utility class that collects static methods used in the Canvas. */
public final class JaxoStaticCanvasMethods {
    private static int nofclicks;
    private static final String[] SYSTEM_FONTS;
    private static int vertexType;
    private static ResourceBundle language;

    //private static Vector points;
    private static int[] points = new int[6];
    private static boolean pointsON;


    static {
        SYSTEM_FONTS =
            GraphicsEnvironment.getLocalGraphicsEnvironment().
                getAvailableFontFamilyNames();
    }

    // Empty private constructor to prevent the class from being instantiated.
    private JaxoStaticCanvasMethods() {
        // empty on purpose
    }

    /** Creates a new JaObject.
     * @param type The type of object to be created (defined in JaxoMainPanel).
     * @param xin The x-coordinate where the object will be created.
     * @param yin The y-coordinate where the object will be created.
     * @return A new JaObject.
     */
    public static JaObject createNewObject(int type, int xin, int yin) {
        JaObject newob = null;


        if (type == JaxoMainPanel.BOX) {
            newob = newBox(xin, yin);
        } else if (type == JaxoMainPanel.BLOB) {
            newob = newBlob(xin, yin);
        } else if (type == JaxoMainPanel.VERTEX) {
            newob = newVertex(xin, yin);
        } else if (type == JaxoMainPanel.ZIGZAG) {
            newob = newZigZagLine(xin, yin);
        } else if (type == JaxoMainPanel.TEXT) {
            newob = newPSText(xin, yin);
        } else if (type == JaxoMainPanel.LATEX) {
            newob = newLatexText(xin, yin);
        } else if (type == JaxoMainPanel.PLINE) {
            newob = newPLine(xin, yin);
        } else if (type == JaxoMainPanel.PARC) {
            newob = newPArc(xin, yin);
        } else if (type == JaxoMainPanel.PLOOP) {
            newob = newPLoop(xin, yin);
        } else if (type == JaxoMainPanel.GLLINE) {
            newob = newGlLine(xin, yin);
        } else if (type == JaxoMainPanel.GLARC) {
            newob = newGlArc(xin, yin);
        } else if (type == JaxoMainPanel.GLLOOP) {
            newob = newGlLoop(xin, yin);
        } else if (type == JaxoMainPanel.FLINE) {
            newob = newFLine(xin, yin);
        } else if (type == JaxoMainPanel.FLOOP) {
            newob = newFLoop(xin, yin);
        } else if (type == JaxoMainPanel.FARC) {
            newob = newFArc(xin, yin);
        } else if (type == JaxoMainPanel.SLINE) {
            newob = newSLine(xin, yin);
        } else if (type == JaxoMainPanel.SLOOP) {
            newob = newSLoop(xin, yin);
        } else if (type == JaxoMainPanel.SARC) {
            newob = newSArc(xin, yin);
        } else if (type == JaxoMainPanel.GLINE) {
            newob = newGLine(xin, yin);
        } else if (type == JaxoMainPanel.GLOOP) {
            newob = newGLoop(xin, yin);
        } else if (type == JaxoMainPanel.GARC) {
            newob = newGArc(xin, yin);
        }

        return newob;
    }

    /** Sets the number of clicks on the canvas (used for arcs).
     * @param clicks The number of clicks.
     */
    public static void setNofClicks(int clicks) {
        nofclicks = clicks;
    }

    /** Sets the language.
     * @param lang The current language.
     */
    public static void setLanguage(ResourceBundle lang) {
        language = lang;
    }

    /** Sets the vector of points (used for arcs).
     * @param newPoints The vector of points.
     */
    public static void setPoints(int[] newPoints) {
        points = newPoints;
    }

    /** Sets the pointsON property (used for arcs).
     * @param on The pointsON property.
     */
    public static void setPointsON(boolean on) {
        pointsON = on;
    }

    /** Sets the vertex type.
     * @param type The type of vertex.
     */
    public static void setVertexType(int type) {
        vertexType = type;
    }

    /** Returns a string array with all the fonts installed on the system.
     * @return A string array with all the fonts installed on the system.
     */
    public static String[] getSystemFonts() {
        return SYSTEM_FONTS;
    }

    /** Returns the pointsON property.
     * @return The new pointsON property.
     */
    public static boolean getPointsON() {
        return pointsON;
    }

    /** Returns the vector of points.
     * @return The new vector of points.
     */
    public static int[] getPoints() {
        return points;
    }

    public static JaObject newBox(int xin, int yin) {
        JaBox newBox = new JaBox();
        newBox.setX(xin);
        newBox.setY(yin);
        newBox.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newBox.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newBox.setFillColor(getDefaultFillColor());

        return (JaObject) newBox;
    }

    public static JaObject newBlob(int xin, int yin) {
        JaBlob newBlob = new JaBlob();
        newBlob.setX(xin);
        newBlob.setY(yin);
        newBlob.setRotAngle(0);
        newBlob.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newBlob.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newBlob.setFillColor(getDefaultFillColor());

        return (JaObject) newBlob;
    }

    public static JaObject newVertex(int xin, int yin) {
        JaObject newob = null;

        if (vertexType == JaxoMainPanel.VERTEXT1) {
            JaVertexT1 newVertexT1 = new JaVertexT1();
            newVertexT1.setX(xin);
            newVertexT1.setY(yin);
            newVertexT1.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newob = (JaObject) newVertexT1;
        } else if (vertexType == JaxoMainPanel.VERTEXT2) {
            JaVertexT2 newVertexT2 = new JaVertexT2();
            newVertexT2.setX(xin);
            newVertexT2.setY(yin);
            newVertexT2.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newVertexT2.setStroke(JaxoPrefs.getFloatPref(
                    JaxoPrefs.PREF_LINEWIDTH));
            newVertexT2.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newVertexT2.setFillColor(JaxoColor.WHITE);
            newob = (JaObject) newVertexT2;
        } else if (vertexType == JaxoMainPanel.VERTEXT3) {
            JaVertexT3 newVertexT3 = new JaVertexT3();
            newVertexT3.setX(xin);
            newVertexT3.setY(yin);
            newVertexT3.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newob = (JaObject) newVertexT3;
        } else if (vertexType == JaxoMainPanel.VERTEXT4) {
            JaVertexT4 newVertexT4 = new JaVertexT4();
            newVertexT4.setX(xin);
            newVertexT4.setY(yin);
            newVertexT4.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newVertexT4.setStroke(JaxoPrefs.getFloatPref(
                    JaxoPrefs.PREF_LINEWIDTH));
            newob = (JaObject) newVertexT4;
        } else if (vertexType == JaxoMainPanel.VERTEXT5) {
            if ((nofclicks % 3) != 0) {
                pointsON = true;

                int pos = (nofclicks % 3) - 1;
                points[2 * pos] = xin;
                points[(2 * pos) + 1] = yin;
            } else {
                pointsON = false;
                points[4] = xin;
                points[5] = yin;

                JaVertexT5 newVertexT5 = new JaVertexT5();
                newVertexT5.setVertexPts(points[0], points[1], points[2],
                    points[3], points[4], points[5]);
                newVertexT5.setStroke(JaxoPrefs.getFloatPref(
                        JaxoPrefs.PREF_LINEWIDTH));
                newVertexT5.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                            JaxoPrefs.PREF_COLOR)));
                newVertexT5.setFillColor(getDefaultFillColor());
                newob = (JaObject) newVertexT5;
            }
        } else if (vertexType == JaxoMainPanel.VERTEXT6) {
            JaVertexT6 newVertexT6 = new JaVertexT6();
            newVertexT6.setX(xin);
            newVertexT6.setY(yin);
            newVertexT6.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newob = (JaObject) newVertexT6;
        }

        return newob;
    }

    public static JaObject newZigZagLine(int xin, int yin) {
        JaZigZagLine newZigZagLine = new JaZigZagLine();
        newZigZagLine.setX(xin);
        newZigZagLine.setY(yin);
        newZigZagLine.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newZigZagLine.setAmp(JaxoPrefs.getIntPref(JaxoPrefs.PREF_AMPLITUDE));
        newZigZagLine.setFreq(20.0f);
        newZigZagLine.setStroke(JaxoPrefs.getFloatPref(
                JaxoPrefs.PREF_LINEWIDTH));
        newZigZagLine.setSymm(false);
        newZigZagLine.setDoubleLine(false);
        newZigZagLine.setDLSeparation(JaxoPrefs.getFloatPref(
                JaxoPrefs.PREF_DLSEP));

        return (JaObject) newZigZagLine;
    }

    public  static JaObject newPSText(int xin, int yin) {
        JaText newText = new JaText();
        String psText = getText();
        if (psText.length() != 0) {
            newText.setX(xin);
            newText.setY(yin);
            newText.setRotAngle(JaxoPrefs.getIntPref(JaxoPrefs.PREF_PSROTANGLE));
            newText.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_TEXTCOLOR)));
            newText.setText(psText);
            newText.setAvailableFonts(SYSTEM_FONTS);
            newText.setFont(new Font(JaxoPrefs.getPref(JaxoPrefs.PREF_PSFAMILY),
                    JaxoPrefs.getIntPref(JaxoPrefs.PREF_PSSTYLE),
                    JaxoPrefs.getIntPref(JaxoPrefs.PREF_PSSIZE)));

            return (JaObject) newText;
        } else {
            return null;
        }
    }

    public static JaObject newLatexText(int xin, int yin) {
        JaLatexText newText = new JaLatexText();
        String latexText = getText();

        if (latexText.length() != 0) {
            newText.setX(xin);
            newText.setY(yin);
            newText.setRotAngle(JaxoPrefs.getIntPref(
                    JaxoPrefs.PREF_TEXROTANGLE));
            newText.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_TEXTCOLOR)));
            newText.setTextString(latexText);
            newText.setAllign(JaxoPrefs.getIntPref(JaxoPrefs.PREF_TEXALIGN));
            newText.setLatexFS(JaxoPrefs.getIntPref(JaxoPrefs.PREF_TEXSIZE));
            newText.createLatexPanel();

            return (JaObject) newText;
        } else {
            return null;
        }
    }

    public static JaObject newPLine(int xin, int yin) {
        JaPLine newPLine = new JaPLine();
        newPLine.setX(xin);
        newPLine.setY(yin);
        newPLine.setAmp(JaxoPrefs.getIntPref(JaxoPrefs.PREF_AMPLITUDE));
        newPLine.setFreq(20.0f);
        newPLine.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newPLine.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newPLine.setSymm(false);
        newPLine.setDoubleLine(false);
        newPLine.setDLSeparation(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_DLSEP));

        return (JaObject) newPLine;
    }

    public static JaObject newPArc(int xin, int yin) {
        JaObject newob = null;

        if ((nofclicks % 3) != 0) {
            pointsON = true;

            int pos = (nofclicks % 3) - 1;
            points[2 * pos] = xin;
            points[(2 * pos) + 1] = yin;
        } else {
            pointsON = false;
            points[4] = xin;
            points[5] = yin;

            JaPArc newPArc = new JaPArc();
            newPArc.setArcPts(points[0], points[1], points[2], points[3],
                points[4], points[5]);
            newPArc.setAmp(-JaxoPrefs.getIntPref(JaxoPrefs.PREF_AMPLITUDE));
            newPArc.setFreq(20.0f);
            newPArc.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newPArc.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
            newPArc.setDoubleLine(false);
            newPArc.setDLSeparation(JaxoPrefs.getFloatPref(
                    JaxoPrefs.PREF_DLSEP));
            newob = (JaObject) newPArc;
        }

        return newob;
    }

    public static JaObject newPLoop(int xin, int yin) {
        JaPLoop newPLoop = new JaPLoop();
        newPLoop.setX(xin);
        newPLoop.setY(yin);
        newPLoop.setAmp(JaxoPrefs.getIntPref(JaxoPrefs.PREF_AMPLITUDE));
        newPLoop.setFreq(20.0f);
        newPLoop.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newPLoop.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newPLoop.setDoubleLine(false);
        newPLoop.setDLSeparation(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_DLSEP));

        return (JaObject) newPLoop;
    }

    public static JaObject newGlLine(int xin, int yin) {
        JaGlLine newGlLine = new JaGlLine();
        newGlLine.setX(xin);
        newGlLine.setY(yin);
        newGlLine.setAmp(JaxoPrefs.getIntPref(JaxoPrefs.PREF_AMPLITUDE));
        newGlLine.setFreq(20.0f);
        newGlLine.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newGlLine.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newGlLine.setSymm(false);
        newGlLine.setDoubleLine(false);
        newGlLine.setDLSeparation(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_DLSEP));

        return (JaObject) newGlLine;
    }

    public static JaObject newGlArc(int xin, int yin) {
        JaObject newob = null;

        if ((nofclicks % 3) != 0) {
            pointsON = true;

            int pos = (nofclicks % 3) - 1;
            points[2 * pos] = xin;
            points[(2 * pos) + 1] = yin;
        } else {
            pointsON = false;
            points[4] = xin;
            points[5] = yin;

            JaGlArc newGlArc = new JaGlArc();
            newGlArc.setArcPts(points[0], points[1], points[2], points[3],
                points[4], points[5]);
            newGlArc.setAmp(JaxoPrefs.getIntPref(JaxoPrefs.PREF_AMPLITUDE));
            newGlArc.setFreq(20.0f);
            newGlArc.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newGlArc.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
            newGlArc.setDoubleLine(false);
            newGlArc.setDLSeparation(JaxoPrefs.getFloatPref(
                    JaxoPrefs.PREF_DLSEP));
            newob = (JaObject) newGlArc;
        }

        return newob;
    }

    public static JaObject newGlLoop(int xin, int yin) {
        JaGlLoop newGlLoop = new JaGlLoop();
        newGlLoop.setX(xin);
        newGlLoop.setY(yin);
        newGlLoop.setAmp(JaxoPrefs.getIntPref(JaxoPrefs.PREF_AMPLITUDE));
        newGlLoop.setFreq(20.0f);
        newGlLoop.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newGlLoop.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newGlLoop.setDoubleLine(false);
        newGlLoop.setDLSeparation(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_DLSEP));

        return (JaObject) newGlLoop;
    }

    public static JaObject newFLine(int xin, int yin) {
        JaFLine newFLine = new JaFLine();
        newFLine.setX(xin);
        newFLine.setY(yin);
        newFLine.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newFLine.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newFLine.setArrow(JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW));
        newFLine.setFlip(false);
        newFLine.setDoubleLine(false);
        newFLine.setDLSeparation(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_DLSEP));

        return (JaObject) newFLine;
    }

    public static JaObject newFLoop(int xin, int yin) {
        JaFLoop newFLoop = new JaFLoop();
        newFLoop.setX(xin);
        newFLoop.setY(yin);
        newFLoop.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newFLoop.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newFLoop.setArrow(JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW));
        newFLoop.setFlip(false);
        newFLoop.setDoubleLine(false);
        newFLoop.setDLSeparation(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_DLSEP));

        return (JaObject) newFLoop;
    }

    public static JaObject newFArc(int xin, int yin) {
        JaObject newob = null;

        if ((nofclicks % 3) != 0) {
            pointsON = true;

            int pos = (nofclicks % 3) - 1;
            points[2 * pos] = xin;
            points[(2 * pos) + 1] = yin;
        } else {
            pointsON = false;
            points[4] = xin;
            points[5] = yin;

            JaFArc newFArc = new JaFArc();
            newFArc.setArcPts(points[0], points[1], points[2], points[3],
                points[4], points[5]);
            newFArc.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newFArc.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
            newFArc.setArrow(JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW));
            newFArc.setFlip(false);
            newFArc.setStangle(0);
            newFArc.setDoubleLine(false);
            newFArc.setDLSeparation(JaxoPrefs.getFloatPref(
                    JaxoPrefs.PREF_DLSEP));
            newob = (JaObject) newFArc;
        }

        return newob;
    }

    public static JaObject newSLine(int xin, int yin) {
        JaSLine newSLine = new JaSLine();
        newSLine.setX(xin);
        newSLine.setY(yin);
        newSLine.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newSLine.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newSLine.setDash(10.0f);
        newSLine.setArrow(JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW));
        newSLine.setFlip(false);
        newSLine.setDoubleLine(false);
        newSLine.setDLSeparation(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_DLSEP));

        return (JaObject) newSLine;
    }

    public static JaObject newSLoop(int xin, int yin) {
        JaSLoop newSLoop = new JaSLoop();
        newSLoop.setX(xin);
        newSLoop.setY(yin);
        newSLoop.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newSLoop.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newSLoop.setDash(10.0f);
        newSLoop.setArrow(JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW));
        newSLoop.setFlip(false);
        newSLoop.setDoubleLine(false);
        newSLoop.setDLSeparation(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_DLSEP));

        return (JaObject) newSLoop;
    }

    public static JaObject newSArc(int xin, int yin) {
        JaObject newob = null;

        if ((nofclicks % 3) != 0) {
            pointsON = true;

            int pos = (nofclicks % 3) - 1;
            points[2 * pos] = xin;
            points[(2 * pos) + 1] = yin;
        } else {
            pointsON = false;
            points[4] = xin;
            points[5] = yin;

            JaSArc newSArc = new JaSArc();
            newSArc.setArcPts(points[0], points[1], points[2], points[3],
                points[4], points[5]);
            newSArc.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newSArc.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
            newSArc.setDash(10.0f);
            newSArc.setArrow(JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW));
            newSArc.setFlip(false);
            newSArc.setStangle(0);
            newSArc.setDoubleLine(false);
            newSArc.setDLSeparation(JaxoPrefs.getFloatPref(
                    JaxoPrefs.PREF_DLSEP));
            newob = (JaObject) newSArc;
        }

        return newob;
    }

    public static JaObject newGLine(int xin, int yin) {
        JaGLine newGLine = new JaGLine();
        newGLine.setX(xin);
        newGLine.setY(yin);
        newGLine.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newGLine.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newGLine.setDash(2.0f);
        newGLine.setArrow(JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW));
        newGLine.setFlip(false);
        newGLine.setDoubleLine(false);
        newGLine.setDLSeparation(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_DLSEP));

        return (JaObject) newGLine;
    }

    public static JaObject newGLoop(int xin, int yin) {
        JaGLoop newGLoop = new JaGLoop();
        newGLoop.setX(xin);
        newGLoop.setY(yin);
        newGLoop.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                    JaxoPrefs.PREF_COLOR)));
        newGLoop.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
        newGLoop.setDash(2.0f);
        newGLoop.setArrow(JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW));
        newGLoop.setFlip(false);
        newGLoop.setDoubleLine(false);
        newGLoop.setDLSeparation(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_DLSEP));

        return (JaObject) newGLoop;
    }

    public static JaObject newGArc(int xin, int yin) {
        JaObject newob = null;

        if ((nofclicks % 3) != 0) {
            pointsON = true;

            int pos = (nofclicks % 3) - 1;
            points[2 * pos] = xin;
            points[(2 * pos) + 1] = yin;
        } else {
            pointsON = false;
            points[4] = xin;
            points[5] = yin;

            JaGArc newGArc = new JaGArc();
            newGArc.setArcPts(points[0], points[1], points[2], points[3],
                points[4], points[5]);
            newGArc.setColor(JaxoColor.getColor(JaxoPrefs.getPref(
                        JaxoPrefs.PREF_COLOR)));
            newGArc.setStroke(JaxoPrefs.getFloatPref(JaxoPrefs.PREF_LINEWIDTH));
            newGArc.setArrow(JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_ARROW));
            newGArc.setFlip(false);
            newGArc.setStangle(0);
            newGArc.setDash(2.0f);
            newGArc.setDoubleLine(false);
            newGArc.setDLSeparation(JaxoPrefs.getFloatPref(
                    JaxoPrefs.PREF_DLSEP));
            newob = (JaObject) newGArc;
        }

        return newob;
    }

    private static String getText() {
        String text = JOptionPane.showInputDialog(null,
                language.getString("Please_enter_a_text:"),
                language.getString("Enter_text"),
                JOptionPane.PLAIN_MESSAGE);

        if (text != null) {
            return text;
        } else {
            return "";
        }
    }

    private static Color getDefaultFillColor() {
        if (JaxoPrefs.getPref(JaxoPrefs.PREF_COLOR).equals(JaxoColor
                    .getColorName(JaxoColor.BLACK))) {
            return (JaxoColor.GRAYSCALE225);
        } else {
            return (JaxoColor.GRAY);
        }
    }
}

 

Ads help maintain this website.