Package com.agifans.picedit.picture

Examples of com.agifans.picedit.picture.EditStatus


                // don't want the user to use the tools within the middle of an existing action.
                if (application.hasVisiblePictureFrame() && !application.getPicture().getCurrentPictureCode().isDataCode()) {
                    Point mousePoint = event.getPoint();
                    Rectangle colourBox = new Rectangle(30, 5, 30, 23);
                    boolean clickInColourBox = colourBox.contains(mousePoint);
                    EditStatus editStatus = application.getEditStatus();
                    Picture picture = application.getPicture();
                   
                    switch (colourType) {
                        case VISUAL:
                            if (editStatus.isVisualDrawEnabled() && !clickInColourBox) {
                                // If click is on the visual button but not in the colour box and visual
                                // drawing is currently on then turn off visual drawing.
                                picture.processVisualColourOff();
                            } else {
                                // Pop up colour chooser.
                                ColourChooserDialog dialog = new ColourChooserDialog(ColourButton.this);
                                dialog.setVisible(true);
                               
                                // Process the chosen visual colour.
                                if (dialog.getChosenColour() != -1) {
                                    picture.processVisualColourChange(dialog.getChosenColour());
                                }
                            }
                            break;
                        case PRIORITY:
                            if (editStatus.isPriorityDrawEnabled() && !clickInColourBox) {
                                // If click is on the priority button but not in the colour box and priority
                                // drawing is currently on then turn off priority drawing.
                                picture.processPriorityColourOff();
                            } else {
                                // Pop up colour chooser.
View Full Code Here


     */
    @SuppressWarnings("unchecked")
    public PictureFrame(final PicEdit application, int initialZoomFactor, String defaultPictureName) {
        this.application = application;
        this.defaultPictureName = defaultPictureName;
        this.editStatus = new EditStatus();
        this.editStatus.setZoomFactor(initialZoomFactor);
        this.picture = new Picture(editStatus);
        this.pictureCodeList = new PictureCodeList(picture);
        this.picture.addPictureChangeListener(pictureCodeList);
        this.egoTestHandler = new EgoTestHandler(editStatus, picture);
View Full Code Here

     * of mouse motion and the updating of the appearance of the mouse cursor. This
     * method is invoked immediately before the application screen repaint.
     */
    public void checkForMouseMotion() {
        Point mousePoint = getPoint();
        EditStatus editStatus = application.getEditStatus();

        // Check if mouse point has changed.
        if (!mousePoint.equals(lastPoint)) {
            if (editStatus.isMenuActive()) {
                // If paused or menu system is active then ignore mouse motion.
            } else {
                // Otherwise process the mouse event as per normal.
                processMouseMove(mousePoint);
            }
View Full Code Here

     *
     * @return the current mouse position.
     */
    public Point getPoint() {
        Point absolutePosition = MouseInfo.getPointerInfo().getLocation();
        EditStatus editStatus = application.getEditStatus();

        int x = ((int) absolutePosition.getX() - diffX) / editStatus.getZoomFactor();
        int y = ((int) absolutePosition.getY() - diffY) / editStatus.getZoomFactor();

        return new Point(x, y);
    }
View Full Code Here

     *
     * @param event the mouse pressed event.
     */
    public void mousePressed(MouseEvent event) {
        Point mousePoint = getPoint();
        EditStatus editStatus = application.getEditStatus();

        if (editStatus.isMenuActive()) {
            // If menu was active and we received a mouse click, then set menu active false again.
            editStatus.setMenuActive(false);
        } else {
            // Otherwise process mouse click as per normal.
            processMouseClick(mousePoint, event.getButton());
           
            // Mouse wheel button, AKA. the middle button. This is not a picture related action, so
            // we process outside of the normal processMouseClick.
            if (event.getButton() == MouseEvent.BUTTON2) {
                // Reset the current tool if line is being drawn. Doesn't make sense to keep line
                // drawing enabled while colour is being chosen.
                if (editStatus.isLineBeingDrawn()) {
                    editStatus.resetTool();
                }
               
                Point eventPoint = event.getLocationOnScreen();
                Point dialogPoint = new Point(eventPoint.x - 34, eventPoint.y - 34);
               
View Full Code Here

     * Invoked when the mouse wheel is moved.
     *
     * @param event the mouse wheel moved event.
     */
    public void mouseWheelMoved(MouseWheelEvent event) {
        EditStatus editStatus = application.getEditStatus();
       
        wheelCounter += event.getWheelRotation();
       
        if (wheelCounter < -1) {
        // Zoom in.
            int zoomFactor = editStatus.getZoomFactor();
            if (zoomFactor < 5) {
                application.resizeScreen(zoomFactor + 1);
            }
            wheelCounter = 0;
      } else if (wheelCounter > 1) {
        // Zoom out.
            int zoomFactor = editStatus.getZoomFactor();
            if (zoomFactor > 1) {
                application.resizeScreen(zoomFactor - 1);
            }
            wheelCounter = 0;
      }
View Full Code Here

    /**
     * Updates the appearance of the mouse cursor depending on where the mouse is and
     * what tool is being used.
     */
    private void updateMouseCursor() {
        EditStatus editStatus = application.getEditStatus();
       
        if (!editStatus.isMenuActive() && mouseIsOverPicture) {
            if ((editStatus.getNumOfClicks() == 0) || editStatus.isFillActive() || editStatus.isBrushActive()) {
                // If the tool is Fill or Brush then show the standard cross hair cursor.
                application.setCursor(crossHairCursor);
            } else {
                // If the tool is Line, Pen or Step then show no cursor (end of line with 'glow' instead).
                application.setCursor(blankCursor);
View Full Code Here

     * Processes the movement of the mouse.
     *
     * @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.
                editStatus.setMousePoint(new Point(x, y));

                // Move the mouse back to the tool adjusted point. This is important
                // when the tool is Pen or Step since these tools are restricted in
                // their movements.
                moveMouseToPictureCoordinates();
View Full Code Here

        JPanel mainPanel = new JPanel();
        mainPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
       
        StatusBarSection toolNamePanel = new StatusBarSection(200) {
            void drawSectionDetail(Graphics2D graphics) {
              EditStatus editStatus = application.getEditStatus();
                graphics.setColor(EgaPalette.BLACK);
                String toolName = null;
                if (editStatus.getTool().equals(ToolType.AIRBRUSH) || editStatus.getTool().equals(ToolType.BRUSH)) {
                  toolName = BrushType.getBrushTypeForBrushCode(editStatus.getBrushCode()).getDisplayName();
                } else {
                  toolName = application.getEditStatus().getTool().toString();
                }
                graphics.drawString(toolName, 8, 15);
            }
        };
       
        StatusBarSection xPanel = new StatusBarSection(75) {
            void drawSectionDetail(Graphics2D graphics) {
                graphics.setColor(EgaPalette.BLACK);
                graphics.drawString(String.format("X: %-3d", application.getEditStatus().getMouseX()), 8, 15);
            }
        };
       
        StatusBarSection yPanel = new StatusBarSection(75) {
            void drawSectionDetail(Graphics2D graphics) {
                graphics.setColor(EgaPalette.BLACK);
                graphics.drawString(String.format("Y: %-3d", application.getEditStatus().getMouseY()), 8, 15);
            }
        };
       
        StatusBarSection priBandPanel = new StatusBarSection(200) {
            void drawSectionDetail(Graphics2D graphics) {
                EditStatus editStatus = application.getEditStatus();
                int priorityBand = editStatus.getPriorityBand();
                graphics.drawString("Priority: " + priorityBand, 8, 15);
                graphics.setColor(EgaPalette.COLOR_OBJECTS[priorityBand]);
                graphics.fillRect(85, 4, 18, 12);
            }
        };
View Full Code Here

            int lastPicturePosition;
            int lastPictureSize;

            boolean shouldPaintOffscreenImage() {
                boolean shouldPaintOffscreenImage = false;
                EditStatus editStatus = getEditStatus();
                Picture picture = getPicture();
               
                // We return true at least every second, but there are other updates that trigger a render immediately.
                if (((editStatus.hasUnrenderedChanges()) || editStatus.isEgoTestEnabled() || !lastPictureBeingDrawn ||
                    ((lastPicturePosition != picture.getPicturePosition()) || (lastPictureSize != picture.getSize()))) &&
                      !picture.isBeingDrawn()) {
                    shouldPaintOffscreenImage = true;
                }
               
                editStatus.clearUnrenderedChanges();
                lastPicturePosition = picture.getPicturePosition();
                lastPictureSize = picture.getSize();
                return shouldPaintOffscreenImage;
            }
View Full Code Here

TOP

Related Classes of com.agifans.picedit.picture.EditStatus

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.