def get_cursor(self): """ Return cursor object. Cursor type and name accessed with object getType and getName methods. """ if not self._cursor: self._cursor = Cursor(Cursor.DEFAULT_CURSOR) return self._cursor
def set_cursor(self, *cursor): """ Set mouse cursor. Alternative arguments: * JVM system cursor or cursor object * image or surface, hotspot (x,y), and optional name * size, hotspot, data, mask, and optional name Refer to pyj2d.cursors for details. """ args = len(cursor) if len(cursor) == 1: if isinstance(cursor[0], int): self._cursor = Cursor(cursor[0]) else: self._cursor = cursor[0] elif args in (2,3): image = cursor[0] hotspot = Point(*cursor[1]) if args == 2: name = 'Custom Cursor' else: name = cursor[2] tk = Toolkit.getDefaultToolkit() self._cursor = tk.createCustomCursor(image, hotspot, name) elif args in (4,5): size = cursor[0] hotspot = Point(*cursor[1]) data = cursor[2] mask = cursor[3] if args == 4: name = 'Custom Cursor' else: name = cursor[4] surface = cursors.create_cursor(size, data, mask) tk = Toolkit.getDefaultToolkit() self._cursor = tk.createCustomCursor(surface, hotspot, name) else: self._cursor = Cursor(Cursor.DEFAULT_CURSOR) if self._cursorVisible: env.jframe.getContentPane().setCursor(self._cursor)
def set_visible(self, visible): """ Set mouse cursor visibility according to visible bool argument. Return previous cursor visibility state. """ visible_pre = self._cursorVisible if visible: if not self._cursor: self._cursor = Cursor(Cursor.DEFAULT_CURSOR) env.jframe.getContentPane().setCursor(self._cursor) self._cursorVisible = True else: if not self._cursorBlank: image = BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB) hotspot = Point(0,0) name = 'Blank Cursor' try: tk = Toolkit.getDefaultToolkit() self._cursorBlank = tk.createCustomCursor(image, hotspot, name) except AWTError: return visible_pre env.jframe.getContentPane().setCursor(self._cursorBlank) self._cursorVisible = False return visible_pre
from javax.swing.tree import TreePath from org.gvsig.fmap.dal.feature.impl import DefaultFeatureStore from org.gvsig.fmap.mapcontext.layers import LayerListener from tocutils import createToCContextMenu from tocutils import addUpdateToCListener #from tocutils import expandAllNodes from tocutils import getIconFromLayer from tocutils import getIconByName from org.gvsig.tools import ToolsLocator from tocutils import getExpansionState from tocutils import setExpansionState from gvsig import logger from gvsig import LOGGER_WARN, LOGGER_INFO, LOGGER_ERROR waitCursor = Cursor(Cursor.WAIT_CURSOR) defaultCursor = Cursor(Cursor.DEFAULT_CURSOR) def setTreeAsSelectionOrder(tree, mapContext): updateAll(tree, mapContext) tree.setCellRenderer(SelectionCellRenderer(tree, mapContext)) tree.addMouseListener(SelectionMouseAdapter(tree, mapContext)) addUpdateToCListener("SelectionOrder", mapContext, UpdateListener(tree, mapContext)) tree.revalidate() tree.repaint() def updateAll(tree, mapContext): exp = getExpansionState(tree)