当前位置: 首页>>代码示例>>Java>>正文


Java MouseEvent.translatePoint方法代码示例

本文整理汇总了Java中java.awt.event.MouseEvent.translatePoint方法的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent.translatePoint方法的具体用法?Java MouseEvent.translatePoint怎么用?Java MouseEvent.translatePoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.event.MouseEvent的用法示例。


在下文中一共展示了MouseEvent.translatePoint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mouseReleased

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * Mouse events are first translated into map coordinates.
 * Then the event is forwarded to the top MouseListener in the
 * stack, if any, otherwise forwarded to all LocalMouseListeners.
 *
 * @see #pushMouseListener
 * @see #popMouseListener
 * @see #addLocalMouseListener
 */
public void mouseReleased(MouseEvent e) {
  Point p = e.getPoint();
  p.translate(theMap.getX(), theMap.getY());
  if (theMap.getBounds().contains(p)) {
    if (!mouseListenerStack.isEmpty()) {
      p = mapCoordinates(e.getPoint());
      e.translatePoint(p.x - e.getX(), p.y - e.getY());
      mouseListenerStack.get(mouseListenerStack.size()-1).mouseReleased(e);
    }
    else if (multicaster != null) {
      p = mapCoordinates(e.getPoint());
      e.translatePoint(p.x - e.getX(), p.y - e.getY());
      multicaster.mouseReleased(e);
    }
    // Request Focus so that keyboard input will be recognized
    theMap.requestFocus();
  }
  // Clicking with mouse always repaints the map
  clearFirst = true;
  theMap.repaint();
  activeMap = this;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:32,代码来源:Map.java

示例2: convertEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
protected MouseEvent convertEvent(MouseEvent e){
  int column = 0;
  int row = rowAtPoint(e.getPoint());

  //move the event from table to tree coordinates
  Rectangle tableCellRect = getCellRect(row, column, false);
  Rectangle treeCellRect = tree.getRowBounds(row);
  int dx = 0;
  if(tableCellRect != null) dx = -tableCellRect.x;
  int dy = 0;
  if(tableCellRect !=null && treeCellRect != null)
    dy = treeCellRect.y -tableCellRect.y;
  e.translatePoint(dx, dy);


  return new MouseEvent(
    tree, e.getID(), e.getWhen(), e.getModifiers(),
    e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()
  );
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:21,代码来源:JTreeTable.java

示例3: snapToGrid

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
public static void snapToGrid(MouseEvent e) {
	int old_x = e.getX();
	int old_y = e.getY();
	int new_x = snapXToGrid(old_x);
	int new_y = snapYToGrid(old_y);
	e.translatePoint(new_x - old_x, new_y - old_y);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:Canvas.java

示例4: zoomEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private void zoomEvent(MouseEvent e, double zoom) {
	int oldx = e.getX();
	int oldy = e.getY();
	int newx = (int) Math.round(e.getX() / zoom);
	int newy = (int) Math.round(e.getY() / zoom);
	e.translatePoint(newx - oldx, newy - oldy);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:Canvas.java

示例5: repairEvent

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
private void repairEvent(MouseEvent e, double zoom) {
	if (zoom != 1.0) {
		int oldx = e.getX();
		int oldy = e.getY();
		int newx = (int) Math.round(e.getX() / zoom);
		int newy = (int) Math.round(e.getY() / zoom);
		e.translatePoint(newx - oldx, newy - oldy);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:10,代码来源:AppearanceCanvas.java

示例6: isCellEditable

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/**
 * This is overridden to forward the event to the tree and start editor timer.
 */
@Override
public boolean isCellEditable(EventObject e) {
    if (lastRow != -1) {
        TreePath tp = tree.getPathForRow(lastRow);
        org.openide.nodes.Node n = tp != null ? Visualizer.findNode(tp.getLastPathComponent()) : null;

        if ((n == null) || !n.canRename()) {
            //return false;
            canEdit = false;
        }
    }

    if (canEdit && (e != null) && (e.getSource() instanceof Timer)) {
        return true;
    }

    if (canEdit && shouldStartEditingTimer(e)) {
        startEditingTimer();
    } else if (shouldStopEditingTimer(e)) {
        timer.stop();
    }

    if (e instanceof MouseEvent) {
        MouseEvent me = (MouseEvent) e;
        int column = getTreeColumnIndex();

        if (SwingUtilities.isLeftMouseButton(me) && (me.getClickCount() == 2)) {
            TreePath path = tree.getPathForRow(TreeTable.this.rowAtPoint(me.getPoint()));
            Rectangle r = tree.getPathBounds(path);

            if ((me.getX() < (r.x - positionX)) || (me.getX() > (r.x - positionX + r.width))) {
                me.translatePoint(r.x - me.getX(), 0);
            }
        }

        MouseEvent newME = new MouseEvent(
                TreeTable.this.tree, me.getID(), me.getWhen(), me.getModifiers()+me.getModifiersEx(),
                me.getX() - getCellRect(0, column, true).x + positionX, me.getY(), me.getClickCount(),
                me.isPopupTrigger()
            );
        TreeTable.this.tree.dispatchEvent(newME);
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:TreeTable.java

示例7: mouseDragged

import java.awt.event.MouseEvent; //导入方法依赖的package包/类
/** A method implemented from the MouseMotionListener interface to handle the splitter dragging */
public void mouseDragged(MouseEvent e) {
    if (continuousLayout == true) {
        Dimension d = getSize();
        Point splitterPos = splitter.getLocation();
        e.translatePoint(splitterPos.x, splitterPos.y);

        if (splitType == VERTICAL) {
            dragPos = e.getY();

            if (dragPos > d.height) {
                dragPos = d.height;
            }
        } else {
            dragPos = e.getX();

            if (dragPos > d.width) {
                dragPos = d.width;
            }
        }

        if (dragPos < 0) {
            dragPos = 0;
        }

        if (continuousLayout) {
            if (dragPos == -1) {
                return;
            }

            int newDragPos = dragPos;

            if (!absolute) {
                if (splitType == VERTICAL) {
                    newDragPos = (100 * dragPos) / d.height;
                } else {
                    newDragPos = (100 * dragPos) / d.width;
                }
            }

            setSplitPosition(newDragPos);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:SplittedPanel.java


注:本文中的java.awt.event.MouseEvent.translatePoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。