List of usage examples for java.awt Cursor W_RESIZE_CURSOR
int W_RESIZE_CURSOR
To view the source code for java.awt Cursor W_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.W_RESIZE_CURSOR)); aWindow.setVisible(true);//from w w w.j a v a2s .c o m }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
private void changeSelectedMask(Point2D point) { switch (getMaskDragIndicator()) { case Cursor.MOVE_CURSOR: moveMask(point);//from ww w . ja v a 2s . 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:com.projity.pm.graphic.gantt.GanttInteractor.java
public Cursor selectCursor() { Cursor cursor = null;//w ww . j a v a 2 s . c o m switch (state) { case BAR_MOVE_START: cursor = new Cursor(Cursor.W_RESIZE_CURSOR); break; case BAR_MOVE_END: cursor = new Cursor(Cursor.E_RESIZE_CURSOR); break; case PROGRESS_BAR_MOVE: cursor = getProgressCursor(); break; case SPLIT: cursor = getSplitCursor(); break; } if (cursor == null) super.selectCursor(); else getGraph().setCursor(cursor); return cursor; }
From source file:JavaXWin.java
public void mouseEntered(MouseEvent e) { if (!m_dragging) setCursor(Cursor.getPredefinedCursor(Cursor.W_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();/*from ww w.ja v a 2 s . c o 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:org.gumtree.vis.plot1d.Plot1DPanel.java
private void changeInternalLegend(MouseEvent e) { // TODO Auto-generated method stub Point2D screenPoint = translateScreenToJava2D(e.getPoint()); //TODO: resize the mask Rectangle2D screenArea = getScreenDataArea(); if (screenArea.contains(screenPoint)) { // Point2D chartPoint = translateScreenToChart(screenPoint); // changeSelectedMask(ChartMaskingUtilities.translateScreenX( // screenPoint.getX(), getScreenDataArea(), getChart())); int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); switch (cursorType) { case Cursor.MOVE_CURSOR: moveLegend(e.getPoint());/*from w w w . j ava 2 s. co m*/ break; case Cursor.W_RESIZE_CURSOR: changeLegendX(e.getPoint()); break; case Cursor.E_RESIZE_CURSOR: changeLegendWidth(e.getPoint()); break; default: break; } repaint(); } }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
protected int findCursorOnSelectedItem(int x, int y) { if (isInternalLegendEnabled && isInternalLegendSelected) { Rectangle2D screenArea = getScreenDataArea(); Rectangle2D legendArea = new Rectangle2D.Double(screenArea.getMaxX() - internalLegendSetup.getMinX(), screenArea.getMinY() + internalLegendSetup.getMinY(), internalLegendSetup.getWidth(), internalLegendSetup.getHeight()); Rectangle2D intersect = screenArea.createIntersection(legendArea); Point2D point = new Point2D.Double(x, y); double minX = legendArea.getMinX(); double maxX = legendArea.getMaxX(); double minY = legendArea.getMinY(); double width = legendArea.getWidth(); double height = legendArea.getHeight(); if (!intersect.isEmpty() && screenArea.contains(point)) { if (width > 8) { Rectangle2D center = new Rectangle2D.Double(minX + 4, minY, width - 8, height); if (screenArea.createIntersection(center).contains(point)) { return Cursor.MOVE_CURSOR; }/* ww w . j a v a2 s .c o m*/ } Rectangle2D west = new Rectangle2D.Double(minX - 4, minY, width < 8 ? width / 2 + 4 : 8, height); if (screenArea.createIntersection(west).contains(point)) { return Cursor.W_RESIZE_CURSOR; } Rectangle2D east = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), minY, width < 8 ? width / 2 + 4 : 8, height); if (screenArea.createIntersection(east).contains(point)) { return Cursor.E_RESIZE_CURSOR; } } } else if (getSelectedMask() != null && !getSelectedMask().isEmpty()) { Rectangle2D screenArea = getScreenDataArea(); Rectangle2D maskArea = ChartMaskingUtilities.getDomainMaskFrame(getSelectedMask(), getScreenDataArea(), getChart()); 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 width = maskArea.getWidth(); double height = maskArea.getHeight(); if (!intersect.isEmpty() && screenArea.contains(point)) { if (width > 8) { Rectangle2D center = new Rectangle2D.Double(minX + 4, minY, width - 8, height); if (screenArea.createIntersection(center).contains(point)) { return Cursor.MOVE_CURSOR; } } Rectangle2D west = new Rectangle2D.Double(minX - 4, minY, width < 8 ? width / 2 + 4 : 8, height); if (screenArea.createIntersection(west).contains(point)) { return Cursor.W_RESIZE_CURSOR; } Rectangle2D east = new Rectangle2D.Double(maxX - (width < 8 ? width / 2 : 4), minY, width < 8 ? width / 2 + 4 : 8, height); if (screenArea.createIntersection(east).contains(point)) { return Cursor.E_RESIZE_CURSOR; } } } return Cursor.DEFAULT_CURSOR; }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
private void changeSelectedMask(double point) { switch (getMaskDragIndicator()) { case Cursor.MOVE_CURSOR: moveMask(point);/*from ww w. j a v a 2s . c o m*/ break; case Cursor.W_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMax(point); } else { changeMaskXMin(point); } break; case Cursor.E_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMin(point); } else { changeMaskXMax(point); } break; default: break; } }
From source file:erigo.ctstream.CTstream.java
/** * //from w w w . java 2 s .com * 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 . j a va 2s .c o 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; } }