Package com.lightcrafts.ui.crop

Examples of com.lightcrafts.ui.crop.CropMode


        return at;
    }

    public static void main(String[] args) {

        final CropMode mode = new CropMode(false);
        mode.addCropListener(
            new CropListener() {
                public void cropCommitted(CropBounds rect) {
                    System.out.println(rect);
                }
                public void unCrop() {
                    System.out.println("uncrop");
                }
            }
        );
        JComponent overlay = mode.getOverlay();
        final Dot dot = new Dot();

        final JPanel panel = new JPanel(new BorderLayout());
        panel.add(overlay);
//        panel.add(dot);

        final JSlider rotor = new JSlider(-45, 45);
        final JSlider scalor = new JSlider(-100, 100);

        rotor.addChangeListener(
            new ChangeListener() {
                public void stateChanged(ChangeEvent event) {
                    int r = rotor.getValue();
                    double angle = r * Math.PI / 180d;
                    int s = scalor.getValue();
                    double scale = Math.pow(10, s / 100d);
                    int x = panel.getWidth() / 2;
                    int y = panel.getHeight() / 2;
                    xform = updateXForm(angle, scale, x, y);
                    mode.setTransform(xform);
                    dot.setTransform(xform);
                }
            }
        );
        scalor.addChangeListener(
            new ChangeListener() {
                public void stateChanged(ChangeEvent event) {
                    int r = rotor.getValue();
                    double angle = r * Math.PI / 180d;
                    int s = scalor.getValue();
                    double scale = Math.pow(10, s / 100d);
                    int x = panel.getWidth() / 2;
                    int y = panel.getHeight() / 2;
                    xform = updateXForm(angle, scale, x, y);
                    mode.setTransform(xform);
                    dot.setTransform(xform);
                }
            }
        );
        Box ctrls = Box.createHorizontalBox();
View Full Code Here


            overlay.popMode();

            // The CropModes need setup and teardown:
            if ((oldMode == cropMode) || (oldMode == rotateMode)) {
                CropMode crop = (CropMode) oldMode;
                crop.doCrop();
            }
            oldMode.exit();
        }
        if (newMode != null) {
            overlay.pushMode(newMode);
            newMode.enter();
        }
        // The CropModes need setup and teardown:
        if ((newMode == cropMode) || (newMode == rotateMode)) {
            CropMode crop = (CropMode) newMode;
            crop.resetCrop();
        }
        // The CropModes need to be kept in sync with each other:
        if (oldMode == cropMode) {
            rotateMode.setCrop(cropMode.getCrop());
        }
View Full Code Here

    }

    CropRotateManager(Engine engine, XFormModel xform) {
        this.engine = engine;
        this.xform = xform;
        rotorMode = new CropMode(true);
        cropMode = new CropMode(false);
        hiddenRotorMode = new RotorMode();
        bounds = new CropBounds();
        undo = new UndoableEditSupport();
        cropMode.addCropListener( new LocalCropListener( "Crop" ) );
        rotorMode.addCropListener( new LocalCropListener( "Rotate" ) );
View Full Code Here

TOP

Related Classes of com.lightcrafts.ui.crop.CropMode

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.