Example usage for java.awt.event MouseEvent MOUSE_DRAGGED

List of usage examples for java.awt.event MouseEvent MOUSE_DRAGGED

Introduction

In this page you can find the example usage for java.awt.event MouseEvent MOUSE_DRAGGED.

Prototype

int MOUSE_DRAGGED

To view the source code for java.awt.event MouseEvent MOUSE_DRAGGED.

Click Source Link

Document

The "mouse dragged" event.

Usage

From source file:Main.java

/**
 * Display mouse events that don't involve mouse motion. The mousemods()
 * method prints modifiers, and is defined below. The other methods return
 * additional information about the mouse event. showLine() displays a line
 * of text in the window. It is defined at the end of this class, along with
 * the paintComponent() method.//from w w w . jav a  2  s  .  c om
 */
public void processMouseEvent(MouseEvent e) {
    String type = null;
    switch (e.getID()) {
    case MouseEvent.MOUSE_DRAGGED:
        type = "MOUSE_DRAGGED";
        break;
    case MouseEvent.MOUSE_RELEASED:
        type = "MOUSE_RELEASED";
        break;
    case MouseEvent.MOUSE_CLICKED:
        type = "MOUSE_CLICKED";
        break;
    case MouseEvent.MOUSE_ENTERED:
        type = "MOUSE_ENTERED";
        break;
    case MouseEvent.MOUSE_EXITED:
        type = "MOUSE_EXITED";
        break;
    }
    showLine(mousemods(e) + type + ": [" + e.getX() + "," + e.getY() + "] " + "num clicks = "
            + e.getClickCount() + (e.isPopupTrigger() ? "; is popup trigger" : ""));

    // When the mouse enters the component, request keyboard focus so
    // we can receive and respond to keyboard events
    if (e.getID() == MouseEvent.MOUSE_ENTERED)
        requestFocus();
}

From source file:MenuChooserApplet.java

public boolean isAppletDragStart(MouseEvent e) {
    if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
        return true;
    } else {//from   www.  j  a  v  a 2s. c  o  m
        return false;
    }
}

From source file:EventTestPane.java

/**
 * Display mouse moved and dragged mouse event. Note that MouseEvent is the
 * only event type that has two methods, two EventListener interfaces and
 * two adapter classes to handle two distinct categories of events. Also, as
 * seen in init(), mouse motion events must be requested separately from
 * other mouse event types./*from  www  .j  av a2 s. c o m*/
 */
public void processMouseMotionEvent(MouseEvent e) {
    String type = null;
    switch (e.getID()) {
    case MouseEvent.MOUSE_MOVED:
        type = "MOUSE_MOVED";
        break;
    case MouseEvent.MOUSE_DRAGGED:
        type = "MOUSE_DRAGGED";
        break;
    }
    showLine(mousemods(e) + type + ": [" + e.getX() + "," + e.getY() + "] " + "num clicks = "
            + e.getClickCount() + (e.isPopupTrigger() ? "; is popup trigger" : ""));
}

From source file:TransferableScribblePane.java

/**
 * This method is called for mouse motion events. We don't have to detect
 * gestures that initiate a drag in this method. That is the job of the
 * DragGestureRecognizer we created in the constructor: it will notify the
 * DragGestureListener defined below./*  w  ww. j  a  v  a 2  s .co m*/
 */
public void processMouseMotionEvent(MouseEvent e) {
    if (e.getID() == MouseEvent.MOUSE_DRAGGED && // If we're dragging
            currentLine != null) { // and a line exists
        currentLine.addSegment(e.getX(), e.getY()); // Add a line segment
        e.consume(); // Eat the event
        repaint(); // Redisplay all lines
    }
    super.processMouseMotionEvent(e); // Invoke any listeners
}

From source file:MouseNavigateTest.java

protected boolean isStartBehaviorEvent(java.awt.event.MouseEvent evt) {
    int nId = evt.getID();
    return ((nId == MouseEvent.MOUSE_DRAGGED) && (evt.isAltDown() == false) && (evt.isMetaDown() == false));
}

From source file:OrientedTest.java

public void processStimulus(Enumeration criteria) {
    WakeupCriterion wakeup;//from w  ww.j  av  a  2s.c om
    AWTEvent[] event;
    int id;
    int dx;

    while (criteria.hasMoreElements()) {
        wakeup = (WakeupCriterion) criteria.nextElement();
        if (wakeup instanceof WakeupOnAWTEvent) {
            event = ((WakeupOnAWTEvent) wakeup).getAWTEvent();
            for (int i = 0; i < event.length; i++) {
                processMouseEvent((MouseEvent) event[i]);

                if (((buttonPress) && ((flags & MANUAL_WAKEUP) == 0))
                        || ((wakeUp) && ((flags & MANUAL_WAKEUP) != 0))) {

                    id = event[i].getID();
                    if ((id == MouseEvent.MOUSE_DRAGGED) && !((MouseEvent) event[i]).isMetaDown()
                            && !((MouseEvent) event[i]).isAltDown()) {

                        x = ((MouseEvent) event[i]).getX();

                        dx = x - x_last;

                        if (!reset) {
                            y_angle = dx * y_factor;

                            transformY.rotY(y_angle);

                            transformGroup.getTransform(currXform);

                            //Vector3d translation = new Vector3d();
                            //Matrix3f rotation = new Matrix3f();
                            Matrix4d mat = new Matrix4d();

                            // Remember old matrix
                            currXform.get(mat);

                            // Translate to origin
                            currXform.setTranslation(new Vector3d(0.0, 0.0, 0.0));
                            if (invert) {
                                currXform.mul(currXform, transformX);
                                currXform.mul(currXform, transformY);
                            } else {
                                currXform.mul(transformX, currXform);
                                currXform.mul(transformY, currXform);
                            }

                            // Set old translation back
                            Vector3d translation = new Vector3d(mat.m03, mat.m13, mat.m23);
                            currXform.setTranslation(translation);

                            // Update xform
                            transformGroup.setTransform(currXform);
                        } else {
                            reset = false;
                        }

                        x_last = x;
                    } else if (id == MouseEvent.MOUSE_PRESSED) {
                        x_last = ((MouseEvent) event[i]).getX();
                    }
                }
            }
        }
    }

    wakeupOn(mouseCriterion);

}

From source file:MouseNavigateTest.java

/**
 * Registers which AWT events are of interest to the behaviour
 *///from   w  ww  .ja  va 2s.c o m
//*****************************************************************************
public void initialize() {
    WakeupCriterion[] mouseEvents = new WakeupCriterion[3];

    mouseEvents[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED);
    mouseEvents[1] = new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED);
    mouseEvents[2] = new WakeupOnAWTEvent(MouseEvent.MOUSE_RELEASED);

    m_MouseCriterion = new WakeupOr(mouseEvents);
    wakeupOn(m_MouseCriterion);
}

From source file:org.yccheok.jstock.gui.charting.InvestmentFlowLayerUI.java

private void processEvent(MouseEvent e, JXLayer layer) {
    if (MouseEvent.MOUSE_DRAGGED == e.getID()) {
        return;/*from  w ww.j  a  va2 s .  c o m*/
    }

    if (MouseEvent.MOUSE_CLICKED == e.getID()) {
        // Transfer focus to chart if user clicks on the chart.
        this.investmentFlowChartJDialog.getChartPanel().requestFocus();
    }

    final Point mousePoint = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), layer);

    final boolean status0 = this.updateInvestPoint(mousePoint);
    final boolean status1 = this.updateROIPoint(mousePoint);

    if (status0 || status1) {
        this.setDirty(true);
    }
}

From source file:MouseNavigateTest.java

protected boolean isStartBehaviorEvent(java.awt.event.MouseEvent evt) {
    int nId = evt.getID();
    return ((nId == MouseEvent.MOUSE_DRAGGED) && (evt.isAltDown() != false) && (evt.isMetaDown() == false));
}

From source file:org.yccheok.jstock.gui.charting.ChartLayerUI.java

private void processEvent(MouseEvent e, JXLayer layer) {
    if (MouseEvent.MOUSE_DRAGGED == e.getID()) {
        return;//from www .ja  v  a 2  s.  c o m
    }

    final Point mousePoint = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), layer);
    if (this.updateMainTraceInfo(mousePoint)) {
        this.updateIndicatorTraceInfos(this.mainTraceInfo.getDataIndex());
        this.setDirty(true);
    }
}