List of usage examples for java.awt Cursor S_RESIZE_CURSOR
int S_RESIZE_CURSOR
To view the source code for java.awt Cursor S_RESIZE_CURSOR.
Click Source Link
From source file:Main.java
public static void main(String[] args) { JFrame aWindow = new JFrame(); aWindow.setBounds(200, 200, 200, 200); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aWindow.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR)); aWindow.setVisible(true);/* w ww. j av a2 s. co m*/ }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
private void changeSelectedMask(Point2D point) { switch (getMaskDragIndicator()) { case Cursor.MOVE_CURSOR: moveMask(point);//from w w w .j a va2s . c o m break; case Cursor.W_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMax(point.getX()); } else { changeMaskXMin(point.getX()); } break; case Cursor.E_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMin(point.getX()); } else { changeMaskXMax(point.getX()); } break; case Cursor.N_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMin(point.getY()); } else { changeMaskYMax(point.getY()); } break; case Cursor.S_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMax(point.getY()); } else { changeMaskYMin(point.getY()); } break; case Cursor.NW_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMax(point.getX()); } else { changeMaskXMin(point.getX()); } if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMin(point.getY()); } else { changeMaskYMax(point.getY()); } break; case Cursor.NE_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMin(point.getX()); } else { changeMaskXMax(point.getX()); } if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMin(point.getY()); } else { changeMaskYMax(point.getY()); } break; case Cursor.SW_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMax(point.getX()); } else { changeMaskXMin(point.getX()); } if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMax(point.getY()); } else { changeMaskYMin(point.getY()); } break; case Cursor.SE_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMin(point.getX()); } else { changeMaskXMax(point.getX()); } if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMax(point.getY()); } else { changeMaskYMin(point.getY()); } break; default: break; } fireMaskUpdateEvent(getSelectedMask()); }
From source file:JavaXWin.java
public void mouseMoved(MouseEvent e) { if (!m_dragging) { if (e.getX() < CORNER) { setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR)); } else if (e.getX() > getWidth() - CORNER) { setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR)); } else {/*from w ww .j a v a 2 s. c om*/ setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR)); } } }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
protected int findCursorOnSelectedItem(int x, int y) { if (getSelectedMask() != null && !getSelectedMask().getRectangleFrame().isEmpty()) { Rectangle2D screenArea = getScreenDataArea(); Rectangle2D maskArea = ChartMaskingUtilities .translateChartRectangle(getSelectedMask(), getScreenDataArea(), getChart()) .getRectangleFrame();// w ww. jav a 2 s. co m Rectangle2D intersect = screenArea.createIntersection(maskArea); Point2D point = new Point2D.Double(x, y); double minX = maskArea.getMinX(); double maxX = maskArea.getMaxX(); double minY = maskArea.getMinY(); double maxY = maskArea.getMaxY(); double width = maskArea.getWidth(); double height = maskArea.getHeight(); if (!intersect.isEmpty() && screenArea.contains(point)) { // if (y > minY && y < maxY) { // if (minX > screenArea.getMinX() + 1 // && minX < screenArea.getMaxX() - 1) { // if (x > minX - 4 && x < minX + (width < 8 ? width / 2 : 4)) { // return Cursor.W_RESIZE_CURSOR; // } // } // if (maxX > screenArea.getMinX() + 1 // && maxX < screenArea.getMaxX() - 1) { // if (x > maxX - (width < 8 ? width / 2 : 4) && x < maxX + 4) { // return Cursor.E_RESIZE_CURSOR; // } // } // } if (height > 8 && width > 8) { Rectangle2D center = new Rectangle2D.Double(minX + 4, minY + 4, width - 8, height - 8); if (screenArea.createIntersection(center).contains(point)) { return Cursor.MOVE_CURSOR; } } if (height > 8) { Rectangle2D west = new Rectangle2D.Double(minX - 4, minY + 4, width < 8 ? width / 2 + 4 : 8, height - 8); if (screenArea.createIntersection(west).contains(point)) { return Cursor.W_RESIZE_CURSOR; } Rectangle2D east = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), minY + 4, width < 8 ? width / 2 + 4 : 8, height - 8); if (screenArea.createIntersection(east).contains(point)) { return Cursor.E_RESIZE_CURSOR; } } if (width > 8) { Rectangle2D north = new Rectangle2D.Double(minX + 4, minY - 4, width - 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(north).contains(point)) { return Cursor.N_RESIZE_CURSOR; } Rectangle2D south = new Rectangle2D.Double(minX + 4, maxY - (height < 8 ? height / 2 : 4), width - 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(south).contains(point)) { return Cursor.S_RESIZE_CURSOR; } } Rectangle2D northwest = new Rectangle2D.Double(minX - 4, minY - 4, width < 8 ? width / 2 + 4 : 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(northwest).contains(point)) { return Cursor.NW_RESIZE_CURSOR; } Rectangle2D northeast = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), minY - 4, width < 8 ? width / 2 + 4 : 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(northeast).contains(point)) { return Cursor.NE_RESIZE_CURSOR; } Rectangle2D southwest = new Rectangle2D.Double(minX - 4, maxY - (height < 8 ? height / 2 : 4), width < 8 ? width / 2 + 4 : 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(southwest).contains(point)) { return Cursor.SW_RESIZE_CURSOR; } Rectangle2D southeast = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), maxY - (height < 8 ? height / 2 : 4), width < 8 ? width / 2 + 4 : 8, height < 8 ? height / 2 + 4 : 8); if (screenArea.createIntersection(southeast).contains(point)) { return Cursor.SE_RESIZE_CURSOR; } } // System.out.println("intersect X:[" + intersect.getMinX() + ", " + // (intersect.getMinX() + intersect.getWidth()) + // "], Y:[" + intersect.getMinY() + ", " + // (intersect.getMinY() + intersect.getHeight()) + // "], x=" + point.getX() + ", y=" + point.getY() + // " " + intersect.contains(point)); } return Cursor.DEFAULT_CURSOR; }
From source file:erigo.ctstream.CTstream.java
/** * //from w ww. ja v a 2s . co m * mouseMoved * * Implement the mouseMoved method defined by interface MouseMotionListener. * * This method is part of our homemade window manager; specifically, this method * handles setting the appropriate mouse cursor based on where the user has * positioned the mouse on the JFrame window. * * Why have we implemented our own window manager? Since translucent panels * can only be contained within undecorated Frames (see comments in the top * header above) and since undecorated Frames don't support moving/resizing, * we implement our own basic "window manager" by catching mouse move and drag * events. * * @author John P. Wilson * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) */ @Override public void mouseMoved(MouseEvent mouseEventI) { // System.err.println("mouseMoved: " + mouseEventI.getX() + "," + mouseEventI.getY()); mouseCommandMode = NO_COMMAND; // Set mouse Cursor based on the current mouse position int commandMode = getGUIFrameCommandMode(mouseEventI.getPoint()); switch (commandMode) { case NO_COMMAND: guiFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); break; case MOVE_FRAME: guiFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); break; case RESIZE_FRAME_NW: guiFrame.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR)); break; case RESIZE_FRAME_N: guiFrame.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR)); break; case RESIZE_FRAME_NE: guiFrame.setCursor(new Cursor(Cursor.NE_RESIZE_CURSOR)); break; case RESIZE_FRAME_E: guiFrame.setCursor(new Cursor(Cursor.E_RESIZE_CURSOR)); break; case RESIZE_FRAME_SE: guiFrame.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR)); break; case RESIZE_FRAME_S: guiFrame.setCursor(new Cursor(Cursor.S_RESIZE_CURSOR)); break; case RESIZE_FRAME_SW: guiFrame.setCursor(new Cursor(Cursor.SW_RESIZE_CURSOR)); break; case RESIZE_FRAME_W: guiFrame.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR)); break; default: guiFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); break; } }
From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java
protected void updateCursorForIndicator() { if (currentIndicator == null) { setCursor(Cursor.getDefaultCursor()); return;/*from w w w . ja va 2 s. co m*/ } switch (currentIndicator) { case NOT_IN_RANGE: setCursor(Cursor.getDefaultCursor()); break; case MOVE: setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); break; case BOTTOM_CENTER: setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR)); break; case BOTTOM_LEFT: setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR)); break; case BOTTOM_RIGHT: setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR)); break; case MIDDLE_LEFT: setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); break; case MIDDLE_RIGHT: setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); break; case TOP_LEFT: setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR)); break; case TOP_CENTER: setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); break; case TOP_RIGHT: setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)); break; } }