Example usage for java.awt.event InputEvent BUTTON1_MASK

List of usage examples for java.awt.event InputEvent BUTTON1_MASK

Introduction

In this page you can find the example usage for java.awt.event InputEvent BUTTON1_MASK.

Prototype

int BUTTON1_MASK

To view the source code for java.awt.event InputEvent BUTTON1_MASK.

Click Source Link

Document

The Mouse Button1 modifier constant.

Usage

From source file:edu.purdue.cc.bionet.ui.GraphVisualizer.java

/**
 * Performs the necessary actions to set up the Graph.
 *///from  w w  w  .j av a 2  s .co m
protected void setup() {
    this.graph = (UndirectedSparseGraph<V, E>) this.getGraphLayout().getGraph();
    this.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<V>());
    //      this.getRenderContext( ).setEdgeLabelTransformer( new ToStringLabeller<E>( ));
    this.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    PluggableGraphMouse mouse = new PluggableGraphMouse() {
        public void mouseWheelMoved(MouseWheelEvent e) {
            scale((float) Math.pow(1.25, -e.getWheelRotation()), e.getPoint());
        }
    };
    mouse.add(new PickingGraphMousePlugin());
    mouse.add(new PickingGraphMousePlugin(-1, InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK));
    this.setGraphMouse(mouse);
    this.getPickedVertexState().addItemListener(this);
    this.getPickedEdgeState().addItemListener(this);
    this.addMouseListener(this);
    this.addComponentListener(new LayoutScaler());

    // set up coloring
    Transformer v = new Transformer<V, Paint>() {
        public Paint transform(V v) {
            if (getPickedVertexState().isPicked(v)) {
                return pickedVertexPaint;
            } else {
                if (commonNeighborIndicator && isCommonNeighbor(v)) {
                    return commonNeighborPaint;
                } else {
                    return vertexPaint;
                }
            }
        }
    };
    Transformer vo = new Transformer<V, Paint>() {
        public Paint transform(V v) {
            if (getPickedVertexState().isPicked(v)) {
                return pickedVertexOutline;
            } else {
                if (commonNeighborIndicator && isCommonNeighbor(v)) {
                    return commonNeighborOutline;
                } else {
                    return vertexOutline;
                }
            }
        }
    };

    this.getRenderContext().setVertexFillPaintTransformer(v);
    this.getRenderContext().setVertexDrawPaintTransformer(vo);

    Transformer e = new Transformer<E, Paint>() {
        public Paint transform(E e) {
            if (getPickedEdgeState().isPicked(e)) {
                return pickedEdgePaint;
            } else {
                return edgePaint;
            }
        }
    };
    this.getRenderContext().setEdgeDrawPaintTransformer(e);
    this.setPickedLabelColor(this.pickedLabelColor);
    this.commonNeighbors = new NeighborCollection<V, E>(this);
}

From source file:com.google.code.facebook.graph.sna.applet.MultiViewDemo.java

/**
 * create an instance of a simple graph in two views with controls to
 * demo the zoom features./*  ww  w .j ava  2  s  .c  o m*/
 * 
 */
public MultiViewDemo() {

    // create a simple graph for the demo
    graph = TestGraphs.getOneComponentGraph();

    // create one layout for the graph
    FRLayout<String, Number> layout = new FRLayout<String, Number>(graph);
    layout.setMaxIterations(1000);

    // create one model that all 3 views will share
    VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>(
            layout, preferredSize);

    // create 3 views that share the same model
    vv1 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);
    vv2 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);
    vv3 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);

    vv1.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<String, Number>());
    vv2.getRenderContext()
            .setVertexShapeTransformer(new ConstantTransformer(new Rectangle2D.Float(-6, -6, 12, 12)));

    vv2.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<String, Number>());

    vv3.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<String, Number>());

    //        transformer = vv1.getLayoutTransformer();
    //        vv2.setLayoutTransformer(transformer);
    //        vv3.setLayoutTransformer(transformer);
    //        
    //        vv2.setViewTransformer(vv1.getViewTransformer());
    //        vv3.setViewTransformer(vv1.getViewTransformer());

    vv2.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer());
    vv3.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer());

    vv1.getRenderContext().getMultiLayerTransformer().addChangeListener(vv1);
    vv2.getRenderContext().getMultiLayerTransformer().addChangeListener(vv2);
    vv3.getRenderContext().getMultiLayerTransformer().addChangeListener(vv3);

    vv1.setBackground(Color.white);
    vv2.setBackground(Color.white);
    vv3.setBackground(Color.white);

    // create one pick support for all 3 views to share
    GraphElementAccessor<String, Number> pickSupport = new ShapePickSupport<String, Number>(vv1);
    vv1.setPickSupport(pickSupport);
    vv2.setPickSupport(pickSupport);
    vv3.setPickSupport(pickSupport);

    // create one picked state for all 3 views to share
    PickedState<Number> pes = new MultiPickedState<Number>();
    PickedState<String> pvs = new MultiPickedState<String>();
    vv1.setPickedVertexState(pvs);
    vv2.setPickedVertexState(pvs);
    vv3.setPickedVertexState(pvs);
    vv1.setPickedEdgeState(pes);
    vv2.setPickedEdgeState(pes);
    vv3.setPickedEdgeState(pes);

    // set an edge paint function that shows picked edges
    vv1.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv2.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv3.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv1.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow));
    vv2.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.blue, Color.cyan));
    vv3.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow));

    // add default listener for ToolTips
    vv1.setVertexToolTipTransformer(new ToStringLabeller());
    vv2.setVertexToolTipTransformer(new ToStringLabeller());
    vv3.setVertexToolTipTransformer(new ToStringLabeller());

    Container content = getContentPane();
    JPanel panel = new JPanel(new GridLayout(1, 0));

    final JPanel p1 = new JPanel(new BorderLayout());
    final JPanel p2 = new JPanel(new BorderLayout());
    final JPanel p3 = new JPanel(new BorderLayout());

    p1.add(new GraphZoomScrollPane(vv1));
    p2.add(new GraphZoomScrollPane(vv2));
    p3.add(new GraphZoomScrollPane(vv3));

    JButton h1 = new JButton("?");
    h1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageOne);
            JOptionPane.showMessageDialog(p1, scrollPane, "View 1", JOptionPane.PLAIN_MESSAGE);
        }
    });
    JButton h2 = new JButton("?");
    h2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageTwo);
            JOptionPane.showMessageDialog(p2, scrollPane, "View 2", JOptionPane.PLAIN_MESSAGE);
        }
    });
    JButton h3 = new JButton("?");
    h3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageThree);
            textArea.setCaretPosition(0);
            JOptionPane.showMessageDialog(p3, scrollPane, "View 3", JOptionPane.PLAIN_MESSAGE);
        }
    });

    // create a GraphMouse for each view
    // each one has a different scaling plugin
    DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse() {
        protected void loadPlugins() {
            pickingPlugin = new PickingGraphMousePlugin();
            animatedPickingPlugin = new AnimatedPickingGraphMousePlugin();
            translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK);
            scalingPlugin = new ScalingGraphMousePlugin(new LayoutScalingControl(), 0);
            rotatingPlugin = new RotatingGraphMousePlugin();
            shearingPlugin = new ShearingGraphMousePlugin();

            add(scalingPlugin);
            setMode(Mode.TRANSFORMING);
        }
    };

    DefaultModalGraphMouse gm2 = new DefaultModalGraphMouse() {
        protected void loadPlugins() {
            pickingPlugin = new PickingGraphMousePlugin();
            animatedPickingPlugin = new AnimatedPickingGraphMousePlugin();
            translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK);
            scalingPlugin = new ScalingGraphMousePlugin(new ViewScalingControl(), 0);
            rotatingPlugin = new RotatingGraphMousePlugin();
            shearingPlugin = new ShearingGraphMousePlugin();

            add(scalingPlugin);
            setMode(Mode.TRANSFORMING);
        }

    };

    DefaultModalGraphMouse gm3 = new DefaultModalGraphMouse() {
    };

    vv1.setGraphMouse(gm1);
    vv2.setGraphMouse(gm2);
    vv3.setGraphMouse(gm3);

    vv1.setToolTipText("<html><center>MouseWheel Scales Layout</center></html>");
    vv2.setToolTipText("<html><center>MouseWheel Scales View</center></html>");
    vv3.setToolTipText(
            "<html><center>MouseWheel Scales Layout and<p>crosses over to view<p>ctrl+MouseWheel scales view</center></html>");

    vv1.addPostRenderPaintable(new BannerLabel(vv1, "View 1"));
    vv2.addPostRenderPaintable(new BannerLabel(vv2, "View 2"));
    vv3.addPostRenderPaintable(new BannerLabel(vv3, "View 3"));

    textArea = new JTextArea(6, 30);
    scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setEditable(false);

    JPanel flow = new JPanel();
    flow.add(h1);
    flow.add(gm1.getModeComboBox());
    p1.add(flow, BorderLayout.SOUTH);
    flow = new JPanel();
    flow.add(h2);
    flow.add(gm2.getModeComboBox());
    p2.add(flow, BorderLayout.SOUTH);
    flow = new JPanel();
    flow.add(h3);
    flow.add(gm3.getModeComboBox());
    p3.add(flow, BorderLayout.SOUTH);

    panel.add(p1);
    panel.add(p2);
    panel.add(p3);
    content.add(panel);

}

From source file:edu.uci.ics.jung.samples.MultiViewDemo.java

/**
 * create an instance of a simple graph in two views with controls to
 * demo the zoom features./*from  www  .  j a  v  a2s. com*/
 * 
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public MultiViewDemo() {

    // create a simple graph for the demo
    graph = TestGraphs.getOneComponentGraph();

    // create one layout for the graph
    FRLayout<String, Number> layout = new FRLayout<String, Number>(graph);
    layout.setMaxIterations(1000);

    // create one model that all 3 views will share
    VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>(
            layout, preferredSize);

    // create 3 views that share the same model
    vv1 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);
    vv2 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);
    vv3 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);

    vv1.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<String, Number>());
    vv2.getRenderContext()
            .setVertexShapeTransformer(new ConstantTransformer(new Rectangle2D.Float(-6, -6, 12, 12)));

    vv2.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<String, Number>());

    vv3.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<String, Number>());

    //        transformer = vv1.getLayoutTransformer();
    //        vv2.setLayoutTransformer(transformer);
    //        vv3.setLayoutTransformer(transformer);
    //        
    //        vv2.setViewTransformer(vv1.getViewTransformer());
    //        vv3.setViewTransformer(vv1.getViewTransformer());

    vv2.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer());
    vv3.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer());

    vv1.getRenderContext().getMultiLayerTransformer().addChangeListener(vv1);
    vv2.getRenderContext().getMultiLayerTransformer().addChangeListener(vv2);
    vv3.getRenderContext().getMultiLayerTransformer().addChangeListener(vv3);

    vv1.setBackground(Color.white);
    vv2.setBackground(Color.white);
    vv3.setBackground(Color.white);

    // create one pick support for all 3 views to share
    GraphElementAccessor<String, Number> pickSupport = new ShapePickSupport<String, Number>(vv1);
    vv1.setPickSupport(pickSupport);
    vv2.setPickSupport(pickSupport);
    vv3.setPickSupport(pickSupport);

    // create one picked state for all 3 views to share
    PickedState<Number> pes = new MultiPickedState<Number>();
    PickedState<String> pvs = new MultiPickedState<String>();
    vv1.setPickedVertexState(pvs);
    vv2.setPickedVertexState(pvs);
    vv3.setPickedVertexState(pvs);
    vv1.setPickedEdgeState(pes);
    vv2.setPickedEdgeState(pes);
    vv3.setPickedEdgeState(pes);

    // set an edge paint function that shows picked edges
    vv1.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv2.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv3.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv1.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow));
    vv2.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.blue, Color.cyan));
    vv3.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow));

    // add default listener for ToolTips
    vv1.setVertexToolTipTransformer(new ToStringLabeller());
    vv2.setVertexToolTipTransformer(new ToStringLabeller());
    vv3.setVertexToolTipTransformer(new ToStringLabeller());

    Container content = getContentPane();
    JPanel panel = new JPanel(new GridLayout(1, 0));

    final JPanel p1 = new JPanel(new BorderLayout());
    final JPanel p2 = new JPanel(new BorderLayout());
    final JPanel p3 = new JPanel(new BorderLayout());

    p1.add(new GraphZoomScrollPane(vv1));
    p2.add(new GraphZoomScrollPane(vv2));
    p3.add(new GraphZoomScrollPane(vv3));

    JButton h1 = new JButton("?");
    h1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageOne);
            JOptionPane.showMessageDialog(p1, scrollPane, "View 1", JOptionPane.PLAIN_MESSAGE);
        }
    });
    JButton h2 = new JButton("?");
    h2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageTwo);
            JOptionPane.showMessageDialog(p2, scrollPane, "View 2", JOptionPane.PLAIN_MESSAGE);
        }
    });
    JButton h3 = new JButton("?");
    h3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageThree);
            textArea.setCaretPosition(0);
            JOptionPane.showMessageDialog(p3, scrollPane, "View 3", JOptionPane.PLAIN_MESSAGE);
        }
    });

    // create a GraphMouse for each view
    // each one has a different scaling plugin
    DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse() {
        protected void loadPlugins() {
            pickingPlugin = new PickingGraphMousePlugin();
            animatedPickingPlugin = new AnimatedPickingGraphMousePlugin();
            translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK);
            scalingPlugin = new ScalingGraphMousePlugin(new LayoutScalingControl(), 0);
            rotatingPlugin = new RotatingGraphMousePlugin();
            shearingPlugin = new ShearingGraphMousePlugin();

            add(scalingPlugin);
            setMode(Mode.TRANSFORMING);
        }
    };

    DefaultModalGraphMouse gm2 = new DefaultModalGraphMouse() {
        protected void loadPlugins() {
            pickingPlugin = new PickingGraphMousePlugin();
            animatedPickingPlugin = new AnimatedPickingGraphMousePlugin();
            translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK);
            scalingPlugin = new ScalingGraphMousePlugin(new ViewScalingControl(), 0);
            rotatingPlugin = new RotatingGraphMousePlugin();
            shearingPlugin = new ShearingGraphMousePlugin();

            add(scalingPlugin);
            setMode(Mode.TRANSFORMING);
        }

    };

    DefaultModalGraphMouse gm3 = new DefaultModalGraphMouse() {
    };

    vv1.setGraphMouse(gm1);
    vv2.setGraphMouse(gm2);
    vv3.setGraphMouse(gm3);

    vv1.setToolTipText("<html><center>MouseWheel Scales Layout</center></html>");
    vv2.setToolTipText("<html><center>MouseWheel Scales View</center></html>");
    vv3.setToolTipText(
            "<html><center>MouseWheel Scales Layout and<p>crosses over to view<p>ctrl+MouseWheel scales view</center></html>");

    vv1.addPostRenderPaintable(new BannerLabel(vv1, "View 1"));
    vv2.addPostRenderPaintable(new BannerLabel(vv2, "View 2"));
    vv3.addPostRenderPaintable(new BannerLabel(vv3, "View 3"));

    textArea = new JTextArea(6, 30);
    scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setEditable(false);

    JPanel flow = new JPanel();
    flow.add(h1);
    flow.add(gm1.getModeComboBox());
    p1.add(flow, BorderLayout.SOUTH);
    flow = new JPanel();
    flow.add(h2);
    flow.add(gm2.getModeComboBox());
    p2.add(flow, BorderLayout.SOUTH);
    flow = new JPanel();
    flow.add(h3);
    flow.add(gm3.getModeComboBox());
    p3.add(flow, BorderLayout.SOUTH);

    panel.add(p1);
    panel.add(p2);
    panel.add(p3);
    content.add(panel);

}

From source file:com.fanniemae.ezpie.actions.HighlightScan.java

private void moveMouseAndClick(int xx, int yy) {
    this._robot.mouseMove(xx, yy);
    this._robot.mousePress(InputEvent.BUTTON1_MASK);
    this._robot.delay(1000); // Click one second
    this._robot.mouseRelease(InputEvent.BUTTON1_MASK);
}

From source file:org.squidy.nodes.MouseIO.java

protected void setSingleMousePress(int button) {
    if (button == MouseEvent.BUTTON1) {
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
    } else if (button == MouseEvent.BUTTON2) {
        robot.mousePress(InputEvent.BUTTON2_MASK);
        robot.mouseRelease(InputEvent.BUTTON2_MASK);

    } else if (button == MouseEvent.BUTTON3) {
        robot.mousePress(InputEvent.BUTTON3_MASK);
        robot.mouseRelease(InputEvent.BUTTON3_MASK);
    }/*  ww  w  . ja  v a  2 s  . c o  m*/
}

From source file:org.squidy.nodes.MouseIO.java

protected void setMouseStatus(int button, boolean status) {
    if (button == MouseEvent.BUTTON1) {
        if (status) {
            robot.mousePress(InputEvent.BUTTON1_MASK);
        } else {//w  w  w.j a  va  2s  .  c o  m
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
        }
    } else if (button == MouseEvent.BUTTON2) {
        if (status) {
            robot.mousePress(InputEvent.BUTTON2_MASK);
        } else {
            robot.mouseRelease(InputEvent.BUTTON2_MASK);
        }
    } else if (button == MouseEvent.BUTTON3) {
        if (status) {
            robot.mousePress(InputEvent.BUTTON3_MASK);
        } else {
            robot.mouseRelease(InputEvent.BUTTON3_MASK);
        }
    }
}

From source file:com.jcraft.weirdx.DDXWindowImpSwing.java

public void mouseEntered(MouseEvent e) {

    if (window != null && window.getFrame() != null) {
        java.awt.Window frame = window.getFrame();
        if ((frame instanceof java.awt.Frame) && frame == e.getSource()) {
            try {
                if (window.isRealized()) {
                    XWindow.setInputFocus(window.client, window.id, 1, (int) System.currentTimeMillis(), false);
                }/*from   www.  j a v  a  2 s  . c  om*/
            } catch (Exception ee) {
                LOG.error(ee);
            }
            return;
        }
    }

    String str = CopyPaste.getString();
    if (!CopyPaste.isOwner() && str != null) {
        synchronized (window.screen.root) {
            Property p = window.screen.root.getProperty();
            while (p != null) {
                if (p.propertyName == 9)
                    break;
                p = p.next;
            }
            if (p != null) {
                p.data = str.getBytes();
                p.size = p.data.length;
            }
        }

        Selection sel = Selection.getSelection(1); // PRIMARY
        if (sel != null && sel.client != null) {
            int time = (int) System.currentTimeMillis();
            Event event = new Event();
            event.mkSelectionClear(time, sel.wid, sel.selection);
            try {
                sel.client.sendEvent(event, 1, Event.NoEventMask, Event.NoEventMask, null);
            } catch (Exception ee) {
                //System.out.println(ee);
            }
            ;
            sel.window = window.screen.root;
            sel.wid = window.screen.root.id;
            sel.lastTimeChanged = time;
            sel.client = null;
        }
        CopyPaste.setString(str);
    }

    if (window.id == window.screen.rootId) {
        return;
    }

    if (window.isMapped()) {
        requestFocus();
        XWindow.focus.win = window.id;
    }

    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    XWindow.sprite.hot.x = x;
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();
    int state = 0;
    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        state |= (1 << 8);
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        state |= (1 << 9);
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        state |= (1 << 10);
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    Client client = window.client;
    if (client == null || client == serverClient)
        return;

    event.mkEnterNotify(0, // Ancestor
            window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 0, // Normal
            0x1 | 0x02 // focus|same-screen
    );
    try {
        XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void mouseEntered(MouseEvent e) {
    if (window == null)
        return;//from w  ww . j  a  v a2 s . c  om
    if (window.getFrame() != null) {
        java.awt.Window frame = window.getFrame();
        if ((frame instanceof java.awt.Frame) && frame == e.getSource()) {
            try {
                if (window.isRealized()) {
                    XWindow.setInputFocus(window.client, window.id, 1, (int) System.currentTimeMillis(), false);
                }
            } catch (Exception ee) {
                LOG.error(ee);
            }
            return;
        }
    }

    String str = CopyPaste.getString();
    if (!CopyPaste.isOwner() && str != null) {
        synchronized (window.screen.root) {
            Property p = window.screen.root.getProperty();
            while (p != null) {
                if (p.propertyName == 9)
                    break;
                p = p.next;
            }
            if (p != null) {
                p.data = str.getBytes();
                p.size = p.data.length;
            }
        }

        Selection sel = Selection.getSelection(1); // PRIMARY
        if (sel != null && sel.client != null) {
            int time = (int) System.currentTimeMillis();
            Event event = new Event();
            event.mkSelectionClear(time, sel.wid, sel.selection);
            try {
                sel.client.sendEvent(event, 1, Event.NoEventMask, Event.NoEventMask, null);
            } catch (Exception ee) {
                //System.out.println(ee);
            }
            ;
            sel.window = window.screen.root;
            sel.wid = window.screen.root.id;
            sel.lastTimeChanged = time;
            sel.client = null;
        }
        CopyPaste.setString(str);
    }

    if (window.id == window.screen.rootId) {
        return;
    }

    if (window.isMapped()) {
        requestFocus();
        XWindow.focus.win = window.id;
    }

    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    XWindow.sprite.hot.x = x;
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();
    int state = 0;
    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        state |= (1 << 8);
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        state |= (1 << 9);
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        state |= (1 << 10);
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    Client client = window.client;
    if (client == null || client == serverClient)
        return;

    event.mkEnterNotify(0, // Ancestor
            window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 0, // Normal
            0x1 | 0x02 // focus|same-screen
    );
    try {
        XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void mouseExited(MouseEvent e) {
    if (window == null)
        return;//from  w  ww .j a  v a2 s  .  c o m

    if (window.id == window.screen.rootId) {
        return;
    }

    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    XWindow.sprite.hot.x = x;
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();
    int state = 0;
    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        state |= (1 << 8);
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        state |= (1 << 9);
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        state |= (1 << 10);
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    Client client = window.client;
    if (client == null || client == serverClient)
        return;

    event.mkLeaveNotify(0, // Ancestor
            window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 0, // Normal
            0x1 | 0x02 // focus|same-screen
    );
    try {
        XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java

/**
 * Gets the InputEvent-ButtonMask of the given mouse button number
 * @param button the button number// ww  w  . j ava 2  s .  c o  m
 * @return the InputEvent button mask
 */
private int getButtonMask(int button) {
    switch (button) {
    case InputConstants.MOUSE_BUTTON_LEFT:
        return InputEvent.BUTTON1_MASK;
    case InputConstants.MOUSE_BUTTON_MIDDLE:
        return InputEvent.BUTTON2_MASK;
    case InputConstants.MOUSE_BUTTON_RIGHT:
        return InputEvent.BUTTON3_MASK;
    default:
        throw new RobotException("unsupported mouse button", null); //$NON-NLS-1$
    }
}