Package org.gephi.preview.api

Examples of org.gephi.preview.api.Vector


    @Override
    public void mouseDragged(MouseEvent e) {
        if (!previewController.sendMouseEvent(buildPreviewMouseEvent(e, PreviewMouseEvent.Type.DRAGGED))) {
            setMoving(true);
            Vector trans = target.getTranslate();
            trans.set(e.getX(), e.getY());
            trans.sub(ref);
            trans.div(target.getScaling()); // ensure const. moving speed whatever the zoom is
            trans.add(lastMove);

            refreshLoop.refreshSketch();
        }
    }
View Full Code Here


        target.reset();
        refreshLoop.refreshSketch();
    }

    private Vector screenPositionToModelPosition(Vector screenPos) {
        Vector center = new Vector(getWidth() / 2f, getHeight() / 2f);
        Vector scaledCenter = Vector.mult(center, target.getScaling());
        Vector scaledTrans = Vector.sub(center, scaledCenter);

        Vector modelPos = new Vector(screenPos.x, screenPos.y);
        modelPos.sub(scaledTrans);
        modelPos.div(target.getScaling());
        modelPos.sub(target.getTranslate());
        return modelPos;
    }
View Full Code Here

            button = PreviewMouseEvent.Button.LEFT;
        } else if (SwingUtilities.isRightMouseButton(evt)) {
            button = PreviewMouseEvent.Button.RIGHT;
        }

        Vector pos = screenPositionToModelPosition(new Vector(mouseX, mouseY));

        return new PreviewMouseEvent((int) pos.x, (int) pos.y, type, button, null);
    }
View Full Code Here

                    g2.setColor(background);
                    g2.fillRect(0, 0, width, height);
                }

                // user zoom
                Vector center = new Vector(width / 2f, height / 2f);
                Vector scaledCenter = Vector.mult(center, scaling);
                Vector scaledTrans = Vector.sub(center, scaledCenter);
                g2.translate(scaledTrans.x, scaledTrans.y);
                g2.scale(scaling, scaling);

                // user move
                g2.translate(trans.x, trans.y);
View Full Code Here

            if (!inited && model != null && model.getDimensions() != null && model.getTopLeftPosition() != null) {

                // initializes zoom
                Dimension dimensions = model.getDimensions();
                Point topLeftPostition = model.getTopLeftPosition();
                Vector box = new Vector((float) dimensions.getWidth(), (float) dimensions.getHeight());
                float ratioWidth = width / box.x;
                float ratioHeight = height / box.y;
                scaling = ratioWidth < ratioHeight ? ratioWidth : ratioHeight;

                // initializes move
                Vector semiBox = Vector.div(box, 2);
                Vector topLeftVector = new Vector((float) topLeftPostition.x, (float) topLeftPostition.y);
                Vector center = new Vector(width / 2f, height / 2f);
                Vector scaledCenter = Vector.add(topLeftVector, semiBox);
                trans.set(center);
                trans.sub(scaledCenter);
//            lastMove.set(trans);

                inited = true;
View Full Code Here

TOP

Related Classes of org.gephi.preview.api.Vector

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.