Package com.agifans.picedit.gui.frame

Examples of com.agifans.picedit.gui.frame.PicturePanel


     *
     * @param mousePoint the Point where the mouse currently is.
     */
    public void processMouseMove(Point mousePoint) {
        EditStatus editStatus = application.getEditStatus();
        PicturePanel picturePanel = application.getPicturePanel();
       
        // Update the status line on every mouse movement.
        editStatus.updateMousePoint(mousePoint);

        int x = editStatus.getMouseX();
        int y = editStatus.getMouseY();
       
        if (editStatus.getNumOfClicks() > 0) {
            // Make sure that the mouse cursor can't leave the picture while a line
            // is being drawn.
            Point clickPoint = editStatus.getClickPoint();
            int clickX = (int) clickPoint.getX();
            int clickY = (int) clickPoint.getY();
            int lineColour = editStatus.getTemporaryLineColour();

            if (editStatus.isLineActive()) {
              picturePanel.drawTemporaryLine(clickX, clickY, x, y, lineColour);
            }
            if (editStatus.isStepActive()) {
                int dX = 0;
                int dY = 0;

                switch (editStatus.getNumOfClicks()) {
                    case 1:
                        dX = x - clickX;
                        dY = y - clickY;
                        if (Math.abs(dX) > Math.abs(dY)) {
                            y = clickY;
                        } else {
                            x = clickX;
                        }
                        picturePanel.drawTemporaryLine(clickX, clickY, x, y, lineColour);
                        break;

                    default:
                        if ((editStatus.isXCornerActive() && ((editStatus.getNumOfClicks() % 2) == 0)) || (editStatus.isYCornerActive() && ((editStatus.getNumOfClicks() % 2) > 0))) {
                            // X and Y corners toggle different direction based on number of clicks. 
                            x = clickX;
                        } else {
                            y = clickY;
                        }
                        picturePanel.drawTemporaryLine(clickX, clickY, x, y, lineColour);
                        break;
                }
            }
            if (editStatus.isPenActive()) {
                x = clickX + adjustForPen(x - clickX, 6);
                y = clickY + adjustForPen(y - clickY, 7);
                picturePanel.drawTemporaryLine(clickX, clickY, x, y, lineColour);
            }
           
            // Move the mouse to the tool restricted x/y position (if applicable).
            if ((robot != null) && ((x != editStatus.getMouseX()) || (y != editStatus.getMouseY()))) {
                // Make sure the EditStatus has the tool adjusted mouse point.
View Full Code Here


     *
     * @param imageFile the image File to load for the background image.
     */
    protected void loadBackgroundImage(File imageFile) {
        EditStatus editStatus = application.getEditStatus();
        PicturePanel picturePanel = application.getPicturePanel();
       
        try {
            Image image = ImageIO.read(imageFile);
            if (image != null) {
                picturePanel.setBackgroundImage(image);
                editStatus.setBackgroundEnabled(true);
            } else {
                picturePanel.setBackgroundImage(null);
                editStatus.setBackgroundEnabled(false);
            }
        } catch (IOException e) {
            picturePanel.setBackgroundImage(null);
            editStatus.setBackgroundEnabled(false);
        }
       
        // This will cause the offscreen image to be recreated, which will remove
        // any rendering artifacts of the previous background.
View Full Code Here

TOP

Related Classes of com.agifans.picedit.gui.frame.PicturePanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.