package usda.weru.weps;

import javax.swing.*; // For JPanel, etc.
import java.awt.*;           // For Graphics, etc.
import java.awt.geom.*;      // For Ellipse2D, etc.
import java.beans.*;
import javax.help.CSH;

/**
 * Creates graphics panel with representation of field dimensions and orientation.
 * Is property change listener to show field and barriers.
 */
public class DrawField extends JPanel implements PropertyChangeListener {

    private static final long serialVersionUID = 1L;

    /**
     * String that shows that North barrier is Selected.
     */
    public static final String SelectN = "BP-N";
    /**
     * String that shows that West barrier is Selected.
     */
    public static final String SelectW = "BP-W";
    /**
     * String that shows that East barrier is Selected.
     */
    public static final String SelectE = "BP-E";
    /**
     * String that shows that South barrier is Selected.
     */
    public static final String SelectS = "BP-S";
    /**
     * String that shows that no barriers are Selected.
     */
    public static final String SelectNone = "BP-D";
    /**
     * String that shows that North barrier is De-Selected.
     */
    public static final String DeselectN = "BP-ND";
    /**
     * String that shows that West barrier is De-Selected.
     */
    public static final String DeselectW = "BP-WD";
    /**
     * String that shows that East barrier is De-Selected.
     */
    public static final String DeselectE = "BP-ED";
    /**
     * String that shows that South barrier is De-Selected.
     */
    public static final String DeselectS = "BP-SD";
    /**
     * String that shows whether the North barrier is visible along the field 
     * or not.
     */
    public static final String ShowN = "BP-SN";
    /**
     * String that shows whether the West barrier is visible along the field 
     * or not.
     */
    public static final String ShowW = "BP-SW";
    /**
     * String that shows whether the East barrier is visible along the field 
     * or not.
     */
    public static final String ShowE = "BP-SE";
    /**
     * String that shows whether the South barrier is visible along the field 
     * or not.
     */
    public static final String ShowS = "BP-SS";
    /**
     * String that allows hiding the North barrier and shows whether it actually is.
     */
    public static final String HideN = "BP-HN";
    /**
     * String that allows hiding the West barrier and shows whether it actually is.
     */
    public static final String HideW = "BP-HW";
    /**
     * String that allows hiding the East barrier and shows whether it actually is.
     */
    public static final String HideE = "BP-HE";
    /**
     * String that allows hiding the South barrier and shows whether it actually is.
     */
    public static final String HideS = "BP-HS";

    /**
     *
     */
    public static final String HideD = "BP-HD";

    /**
     *
     */
    public static final String ShowD = "BP-SD";

    private boolean drawE = false;
    private boolean drawW = false;
    private boolean drawN = false;
    private boolean drawS = false;
    private boolean showE = false;
    private boolean showS = false;
    private boolean showN = false;
    private boolean showW = false;
    private boolean c_approximateRegion = false;
    private String c_shape = "rectangle";
    private boolean drawnToScaleFlag = true;
    private double c_scaleY = 1.0;
    private double c_scaleX = 1.0;
//    private boolean showD=false;
    private boolean drawD = false;

    /**
     * 
     *@param g2d
     *@param a
     *@param b
     *@param c
     *@param d
     *@param isShow
     */
    private void drawSelected(Graphics2D g2d, double a, double b,
            double c, double d, boolean isShow) {
        if (isShow) {
            GradientPaint gradient = new GradientPaint((float) a, (float) b,
                    Color.red, (float) a + 10, (float) b + 10, Color.yellow, true);
//			Color.red, (float) c, (float) d, Color.green, true);
            g2d.setPaint(gradient);
            Rectangle2D.Double rect = new Rectangle2D.Double(a, b, c, d);
            g2d.fill(rect);
            g2d.setPaint(Color.red);
            g2d.draw(rect);
        } else {
            Rectangle2D.Double rect = new Rectangle2D.Double(a, b, c, d);
            g2d.setPaint(Color.yellow);
            g2d.fill(rect);
        }
    }

    private void scale() {
        SXLen *= c_scaleX;
        SYLen *= c_scaleY;
    }

    private void showSelected(Graphics2D g2d, double a, double b,
            double c, double d) {

        Rectangle2D.Double rect = new Rectangle2D.Double(a, b, c, d);
        g2d.setPaint(Color.red);
        g2d.fill(rect);
    }
//	private Rectangle2D.Double border =
//			new Rectangle2D.Double(10, 10, 190, 190);

//  private Rectangle2D.Double square2 =
//	new Rectangle2D.Double(50, 50, 100, 100);
    static int rotCount = 0;
    private final Rectangle2D.Double square2
            = new Rectangle2D.Double(-50, -50, 100, 100);
    private Rectangle clipRect = null;

    /**
     * This method paints/repaints the visual source on the GUI by calling its native functions and 
     * stabilizes the picture on the view.
     * @param g The object that is used to redraws the graphical nature of the image.
     */
    @Override
    public void paintComponent(Graphics g) {
        clear(g);
        Graphics2D g2d = (Graphics2D) g;
//	Rectangle clipRect = g2d.getClipBounds();
        if (clipRect == null) {
            clipRect = g2d.getClipBounds();
        }
        if (clipRect == null) {
            clipRect = getBounds();
            clipRect.x = 0;
            clipRect.y = 0;
        }

//	Rectangle2D.Double border = new Rectangle2D.Double(10, 10,
//		clipRect.width-20, clipRect.height-20);
//    g2d.draw(border);
////System.out.println("DF_pC: g size " + g2d.getClipBounds());
        // Move the origin to the center of the square.
        drawCompass(g2d);
        g2d.translate(clipRect.width / 2, clipRect.height / 2);
//	g2d.translate(105.0, 105.0);
        if (SYLen < SXLen / 10.0) {
            SYLen = SXLen / 10.0;
            drawnToScaleFlag = false;
        } else if (SXLen < SYLen / 10.0) {
            SXLen = SYLen / 10.0;
            drawnToScaleFlag = false;
        }
        if (!drawnToScaleFlag) {
            g2d.drawString("Field not drawn to scale", -90, 90);
        }
        if (c_approximateRegion) {
            g2d.drawString("Field shape approximate", -90, 90);
        }
        //	drawCompass(g2d);
        if (drawN || drawS || drawE || drawW) {
            g2d.drawString("Barriers not to scale", -90, -80);
        } else {
            //        g2d.drawString("None Barrier",0,0);    //by JG
        }

        g2d.rotate(Angle * Math.PI / 180.0);
//	g2d.drawString("X-Length", -15, 90);
        g2d.drawString("X-Length", -25, (int) (SYLen / 2) + 20);
        g2d.rotate(90 * Math.PI / 180.0);
//	g2d.drawString("Y-Length", -15, 90);
        g2d.drawString("Y-Length", -25, (int) (SXLen / 2) + 20);
        g2d.rotate(270 * Math.PI / 180.0);
//	g2d.rotate(Angle * Math.PI/180.0);		this is where rotate was

        if (isShape(RegPanel.SHAPE_CIRCLE)) {//Circle
            g2d.setPaint(Color.GREEN);
            int circleWidth = (int) (Math.sqrt((SXLen * SYLen) / Math.PI) * 2);
            int circleHeight = circleWidth;
            int circleX = (0 - circleWidth / 2);
            int circleY = circleX;

            g2d.fillOval(circleX, circleY, circleWidth, circleHeight);
        } else if (isShape(RegPanel.SHAPE_HALF_CIRCLE_HS)) {//Half circle HS
            double radius = Math.sqrt((SXLen * SXLen) / Math.PI);
            double point1X = 0 - radius;
            double point1Y = 0 - radius / 2;
            double point2X = radius;
            double point2Y = point1Y;

            double control1X = point1X;
            double control1Y = ((4 * radius) + point1Y) / 3 + point1Y / 2;
            double control2X = point2X;
            double control2Y = control1Y;
            CubicCurve2D cubic = new CubicCurve2D.Double(point1X, point1Y, control1X, control1Y, control2X,
                    control2Y, point2X, point2Y);
            g2d.setColor(Color.GREEN);
            g2d.fill(cubic);
        } else if (isShape(RegPanel.SHAPE_HALF_CIRCLE_HN)) {//Half circle HN
            double radius = Math.sqrt((SXLen * SXLen) / Math.PI);
            double point1X = 0 - radius;
            double point1Y = radius / 2;
            double point2X = radius;
            double point2Y = point1Y;

            double control1X = point1X;
            double control1Y = 0 - ((4 * radius) - point1Y) / 3 + point1Y / 2;
            double control2X = point2X;
            double control2Y = control1Y;
            CubicCurve2D cubic = new CubicCurve2D.Double(point1X, point1Y, control1X, control1Y, control2X,
                    control2Y, point2X, point2Y);
            g2d.setColor(Color.GREEN);
            g2d.fill(cubic);
        } else if (isShape(RegPanel.SHAPE_HALF_CIRCLE_VE)) {//Half circle VE
            double radius = Math.sqrt((SYLen * SYLen) / Math.PI);
            double point1Y = 0 - radius;
            double point1X = 0 - radius / 2;
            double point2Y = radius;
            double point2X = point1X;

            double control1Y = point1Y;
            double control1X = ((4 * radius) + point1X) / 3 + point1X / 2;
            double control2Y = point2Y;
            double control2X = control1X;
            CubicCurve2D cubic = new CubicCurve2D.Double(point1X, point1Y, control1X, control1Y, control2X,
                    control2Y, point2X, point2Y);
            g2d.setColor(Color.GREEN);
            g2d.fill(cubic);
        } else if (isShape(RegPanel.SHAPE_HALF_CIRCLE_VW)) {//Half circle VW
            double radius = Math.sqrt((SYLen * SYLen) / Math.PI);
            double point1Y = 0 - radius;
            double point1X = radius / 2;
            double point2Y = radius;
            double point2X = point1X;

            double control1Y = point1Y;
            double control1X = 0 - ((4 * radius) - point1X) / 3 + point1X / 2;
            double control2Y = point2Y;
            double control2X = control1X;
            CubicCurve2D cubic = new CubicCurve2D.Double(point1X, point1Y, control1X, control1Y, control2X,
                    control2Y, point2X, point2Y);
            g2d.setColor(Color.GREEN);
            g2d.fill(cubic);
        } else if (isShape(RegPanel.SHAPE_QUARTER_CIRCLE_NE)) {//Quarter Circles
            double radius = Math.sqrt((SXLen * SYLen * 4) / Math.PI);
            g2d.setColor(Color.GREEN);
            Arc2D arc = new Arc2D.Double(0 - radius / 2 - radius, 0 - radius / 2, radius * 2, radius * 2, 0d,
                    (Math.PI * radius * 2) / 8, Arc2D.PIE);
            g2d.fill(arc);
        } else if (isShape(RegPanel.SHAPE_QUARTER_CIRCLE_SE)) {//Quarter Circles
            double radius = Math.sqrt((SXLen * SYLen * 4) / Math.PI);
            g2d.setColor(Color.GREEN);
            Arc2D arc = new Arc2D.Double(0 - radius / 2 - radius, 0 - radius / 2 - radius, radius * 2,
                    radius * 2, -90d, (Math.PI * radius * 2) / 8, Arc2D.PIE);
            g2d.fill(arc);
        } else if (isShape(RegPanel.SHAPE_QUARTER_CIRCLE_SW)) {//Quarter Circles
            double radius = Math.sqrt((SXLen * SYLen * 4) / Math.PI);
            g2d.setColor(Color.GREEN);
            Arc2D arc = new Arc2D.Double(0 - radius / 2, 0 - radius / 2 - radius, radius * 2, radius * 2, 180,
                    (Math.PI * radius * 2) / 8, Arc2D.PIE);
            g2d.fill(arc);
        } else if (isShape(RegPanel.SHAPE_QUARTER_CIRCLE_NW)) {//Quarter Circles
            double radius = Math.sqrt((SXLen * SYLen * 4) / Math.PI);
            g2d.setColor(Color.GREEN);
            Arc2D arc = new Arc2D.Double(0 - radius / 2, 0 - radius / 2, radius * 2, radius * 2, 90d,
                    (Math.PI * radius * 2) / 8, Arc2D.PIE);
            g2d.fill(arc);
        }

        if (SXLen != 0.0 && SYLen != 0.0) {
            if (c_approximateRegion) {
                //The square region is approximated for a circle or half circle or quarter circle.
                g2d.setPaint(Color.BLACK);
                g2d.draw(new Rectangle2D.Double(-SXLen / 2, -SYLen / 2, SXLen, SYLen));
            } else {
                //Paint a filled square region
                g2d.setPaint(Color.GREEN);
                g2d.fill(new Rectangle2D.Double(-SXLen / 2, -SYLen / 2, SXLen, SYLen));
                g2d.setPaint(Color.BLACK);
                g2d.draw(new Rectangle2D.Double(-SXLen / 2, -SYLen / 2, SXLen, SYLen));
            }

            g2d.setPaint(Color.red);
            if (showN) {
                showSelected(g2d, -SXLen / 2, -(SYLen + 20) / 2, SXLen, 10);
            }
            if (showW) {
                showSelected(g2d, -(SXLen + 20) / 2, -SYLen / 2, 10, SYLen);
            }
            if (showS) {
                showSelected(g2d, -SXLen / 2, SYLen / 2, SXLen, 10);
            }
            if (showE) {
                showSelected(g2d, SXLen / 2, -SYLen / 2, 10, SYLen);
            }

            if (drawN) {
                drawSelected(g2d, -SXLen / 2, -(SYLen + 20) / 2, SXLen, 10, showN);
            } else if (drawW) {
                drawSelected(g2d, -(SXLen + 20) / 2, -SYLen / 2, 10, SYLen, showW);
            } else if (drawS) {
                drawSelected(g2d, -SXLen / 2, SYLen / 2, SXLen, 10, showS);
            } else if (drawE) {
                drawSelected(g2d, SXLen / 2, -SYLen / 2, 10, SYLen, showE);
            }
        }
    }

    private void drawCompass(Graphics2D g2d) {
        g2d.setPaint(Color.blue);
//	  Rectangle clipRect = g2d.getClipBounds();
        g2d.translate(clipRect.width - 30, 20);
        int[] xpoints = {5, 10, 10, 6, 6, 4, 4, 0, 0};

        int[] ypoints = {0, 5, 7, 2, 30, 30, 2, 7, 5};
//	  int[] xpoints = {85, 90, 90, 86, 86, 84, 84, 80, 80};
        //int[] ypoints = {-15, -10, -8, -13, 15, 15, -13, -8, -10};
//	  int[] ypoints = {-90, -85, -83, -88, -60, -60, -88, -83, -85};
        Polygon arrow = new Polygon(xpoints, ypoints, xpoints.length);
        g2d.fill(arrow);
        g2d.setPaint(Color.black);
        //g2d.drawString("N", 80, 5);
////System.out.println("DF_dC: " + g2d.getClipBounds());

//	Rectangle2D.Double border = new Rectangle2D.Double(10, 10,
//		clipRect.width-20, clipRect.height-20);
//	  g2d.drawString("N", 80, -70);
        g2d.drawString("N", 0, 20);
        g2d.translate(-(clipRect.width - 30), -20);
    }

    // super.paintComponent clears offscreen pixmap,
    // since we're using double buffering by default.
    /**
     * Clears the screen from the barrier drawing that were drawn on te GUI panel for displaying the
     * field details or existance.
     * @param g The graphics object used to clear the contents from the screen acting as an eraser.
     */
    protected void clear(Graphics g) {
        super.paintComponent(g);
    }

    /**
     * Default constructor for the class that initialises some basic things and calls 
     * its super constructor which is from the panel.
     */
    public DrawField() {
        super();
        setToolTipText("DrawField:main");

        //{{INIT_CONTROLS
        setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        setSize(0, 0);
        addHelp();
    //clipRect = new Rectangle(getSize());
        //$$ lineBorder1.move(0,1);
        //}}
    }

    /**
     * This method is used if this dialog is rum as an independent application. If executed,
     * makes the GUI visible.
     * @param args These are the command line arguments passed to the main method.
     */
    public static void main(String[] args) {
//    WindowUtilities.openInJFrame(new DrawField(), 240, 260);
//	JFrame frame = new JFrame(title);
        JFrame frame = new JFrame("Draw Field Test");
        frame.setBackground(Color.white);
        DrawField df = new DrawField();
        df.XLen = 100;
        df.YLen = 80;
        df.setBackground(Color.white);
        df.addPropertyChangeListener(df);
        frame.setSize(240, 260);
//	frame.setContentPane(content);
        frame.setContentPane(df);
//	frame.addWindowListener(new ExitListener());
        frame.setVisible(true);

        df.propertyChange(new PropertyChangeEvent(df, RunFileData.XLength, null, "100"));
        df.propertyChange(new PropertyChangeEvent(df, RunFileData.YLength, null, "80"));
        try {
//	    df.changes.firePropertyChange(ShowN, null, "");
            df.propertyChange(new PropertyChangeEvent(df, ShowN, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, ShowS, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, ShowE, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, ShowW, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, SelectN, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, SelectS, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, SelectE, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, SelectW, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, SelectNone, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, HideN, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, HideS, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, HideE, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, HideW, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, SelectN, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, DeselectN, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, SelectS, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, DeselectS, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, SelectE, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, DeselectE, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, SelectW, null, ""));
            Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, DeselectW, null, ""));
            Thread.sleep(1000);
  //          df.propertyChange(new PropertyChangeEvent(df, ShowD, null, ""));
            //         Thread.sleep(1000);
            df.propertyChange(new PropertyChangeEvent(df, HideD, null, ""));
            Thread.sleep(1000);
        } catch (java.lang.InterruptedException f) {
        }
        System.exit(0);
    }
    double XLen = 0;
    double YLen = 0;
    double Radius = 0;
    double Angle = 30;
    double SYLen = 0;
    double SXLen = 0;

    private boolean isShape(String test) {
        return c_shape.equals(test);
    }

    /**
     * 
     */
    public void reset() {
        drawN = false;
        drawE = false;
        drawS = false;
        drawW = false;

        showN = false;
        showE = false;
        showS = false;
        showW = false;
    }

    /**
     * Listens and updates changes to incorporate the modifications intended by an event trigger on the 
     * same or a different GUI component being registered to listen or react based on
     * @param e The event triggered when some property that is registered with this object happen to
     * undergo changes due to user interaction or other screen's event generation.
     */
    @Override
    public void propertyChange(PropertyChangeEvent e) {
        //     System.out.println("DF-pC: " + e.getPropertyName());
        if (e.getPropertyName().equals(RunFileData.ResetBarriers)) {
            reset();
        } else if (e.getPropertyName().equals(RunFileData.Shape)) {
            c_shape = e.getNewValue().toString();
            if (isShape(RegPanel.SHAPE_CIRCLE) || isShape(RegPanel.SHAPE_HALF_CIRCLE_HS)
                    || isShape(RegPanel.SHAPE_HALF_CIRCLE_HN) || isShape(RegPanel.SHAPE_HALF_CIRCLE_VE)
                    || isShape(RegPanel.SHAPE_HALF_CIRCLE_VW) || isShape(RegPanel.SHAPE_QUARTER_CIRCLE_NE)
                    || isShape(RegPanel.SHAPE_QUARTER_CIRCLE_SE) || isShape(RegPanel.SHAPE_QUARTER_CIRCLE_SW)
                    || isShape(RegPanel.SHAPE_QUARTER_CIRCLE_NW)) {
                c_approximateRegion = true;
            } else {
                c_approximateRegion = false;
            }

            repaint();
        } else if (e.getPropertyName().equals(RunFileData.Radius)) {
            drawnToScaleFlag = true;
            try {
                Radius = Double.parseDouble((String) e.getNewValue());
            } catch (NumberFormatException k) {
                //System.err.println("RP-pC: bad Radius from rfd " + k);
            }
            repaint();
        } else if (e.getPropertyName().equals(RunFileData.XLength)) {
            drawnToScaleFlag = true;
            try {
                XLen = Double.parseDouble((String) e.getNewValue());
            } catch (NumberFormatException k) {
                //System.err.println("RP-pC: bad XLen from rfd " + k);
            }
            if (XLen == 0 || YLen == 0) {
                return;
            }
            if (XLen > YLen) {
                SXLen = 100;
                SYLen = (YLen / XLen) * 100;
            } else {
                SYLen = 100;
                SXLen = (XLen / YLen) * 100;
            }
            scale();
            repaint();
        } else if (e.getPropertyName().equals(RunFileData.YLength)) {
            drawnToScaleFlag = true;
            try {
                YLen = Double.parseDouble((String) e.getNewValue());
            } catch (NumberFormatException k) {
                //System.err.println("RP-pC: bad XLen from rfd " + k);
            }
            if (XLen == 0 || YLen == 0) {
                return;
            }
            if (XLen > YLen) {
                SXLen = 100;
                SYLen = (YLen / XLen) * 100;
            } else {
                SYLen = 100;
                SXLen = (XLen / YLen) * 100;
            }
            scale();
            repaint();
        } else if (e.getPropertyName().equals(RunFileData.RegionAngle)) {
            try {
                Angle = Double.parseDouble((String) e.getNewValue());
            } catch (NumberFormatException k) {
                //System.err.println("RP-pC: bad XLen from rfd " + k);
            }
            repaint();
        } else if (e.getPropertyName().equals(SelectN)) {
            drawN = true;
            drawE = false;
            drawW = false;
            drawS = false;
            repaint();
        } else if (e.getPropertyName().equals(SelectE)) {
            drawE = true;
            drawW = false;
            drawS = false;
            drawN = false;
            repaint();
        } else if (e.getPropertyName().equals(SelectS)) {
            drawS = true;
            drawN = false;
            drawE = false;
            drawW = false;
            repaint();
        } else if (e.getPropertyName().equals(SelectW)) {
            drawW = true;
            drawN = false;
            drawE = false;
            drawS = false;
            repaint();
        } else if (e.getPropertyName().equals(SelectNone)) {
            drawW = false;
            drawN = false;
            drawE = false;
            drawS = false;
            drawD = true;
            repaint();
        } else if (e.getPropertyName().equals(DeselectN)) {
            drawN = false;
            repaint();
        } else if (e.getPropertyName().equals(DeselectE)) {
            drawE = false;
            repaint();
        } else if (e.getPropertyName().equals(DeselectS)) {
            drawS = false;
            repaint();
        } else if (e.getPropertyName().equals(DeselectW)) {
            drawW = false;
            repaint();
        } else if (e.getPropertyName().equals(ShowE)) {
            showE = true;
            repaint();
        } else if (e.getPropertyName().equals(ShowW)) {
            showW = true;
            repaint();
        } else if (e.getPropertyName().equals(ShowN)) {
            showN = true;
            repaint();
        } else if (e.getPropertyName().equals(ShowS)) {
            showS = true;
            repaint();
        } else if (e.getPropertyName().equals(HideE)) {
            showE = false;
            repaint();
        } else if (e.getPropertyName().equals(HideW)) {
            showW = false;
            repaint();
        } else if (e.getPropertyName().equals(HideN)) {
            showN = false;
            repaint();
        } else if (e.getPropertyName().equals(HideS)) {
            showS = false;
            repaint();
        }
    }

    /**
     *
     * @param scaleX
     * @param scaleY
     */
    public void setSpecialCaseHackFactor(double scaleX, double scaleY) {
        c_scaleX = scaleX;
        c_scaleY = scaleY;
    }
    
    private void addHelp() {
        CSH.setHelpIDString(this, "drawPanel_html");
    }

    //{{DECLARE_CONTROLS
//	com.symantec.itools.javax.swing.borders.LineBorder lineBorder1 = new com.symantec.itools.javax.swing.borders.LineBorder();
    //}}
}
