List of usage examples for java.awt Cursor CROSSHAIR_CURSOR
int CROSSHAIR_CURSOR
To view the source code for java.awt Cursor CROSSHAIR_CURSOR.
Click Source Link
From source file:rod_design_compute.ShowPanel.java
private void formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseMoved // TODO add your handling code here: if (parent.getStatus() == parent.FOCUS) { this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); choosePoint = null;// w w w . j a v a 2 s . c o m chooseRod = null; for (int i = 0; i < parent.arrayRodGroup.size(); i++) { if (choosePoint != null || chooseRod != null) break; chooseIndex = i; switch (parent.arrayRodGroup.get(i).getType()) { case RodGroup.SR: SR sr = (SR) (parent.arrayRodGroup.get(i)); if (distance(evt.getX(), evt.getY(), sr.getPointA()) < minDistance) choosePoint = sr.getPointA(); else if (distance(evt.getX(), evt.getY(), sr.getPointB()) < minDistance) choosePoint = sr.getPointB(); else if (sr.flag == true && distance(evt.getX(), evt.getY(), sr.getPointE()) < minDistance) choosePoint = sr.getPointE(); else if (distance(evt.getX(), evt.getY(), sr.getPointA(), sr.getPointB()) < minDistance) { chooseRod = sr.getL_dangan(); chooseRodPoint1 = sr.getPointA(); chooseRodPoint2 = sr.getPointB(); } break; case RodGroup.RRR: RRR rrr = (RRR) (parent.arrayRodGroup.get(i)); if (distance(evt.getX(), evt.getY(), rrr.getPointB()) < minDistance) choosePoint = rrr.getPointB(); else if (distance(evt.getX(), evt.getY(), rrr.getPointC()) < minDistance) choosePoint = rrr.getPointC(); else if (distance(evt.getX(), evt.getY(), rrr.getPointD()) < minDistance) choosePoint = rrr.getPointD(); else if ((rrr.flag2 == true || rrr.flag3 == true) && distance(evt.getX(), evt.getY(), rrr.getPointE()) < minDistance) choosePoint = rrr.getPointE(); else if (distance(evt.getX(), evt.getY(), rrr.getPointB(), rrr.getPointC()) < minDistance) { chooseRod = rrr.getrodL2(); chooseRodPoint1 = rrr.getPointB(); chooseRodPoint2 = rrr.getPointC(); } else if (distance(evt.getX(), evt.getY(), rrr.getPointC(), rrr.getPointD()) < minDistance) { chooseRod = rrr.getrodL3(); chooseRodPoint1 = rrr.getPointC(); chooseRodPoint2 = rrr.getPointD(); } break; case RodGroup.RRP: RRP rrp = (RRP) (parent.arrayRodGroup.get(i)); if (distance(evt.getX(), evt.getY(), rrp.getPointB()) < minDistance) choosePoint = rrp.getPointB(); else if (distance(evt.getX(), evt.getY(), rrp.getPointC()) < minDistance) choosePoint = rrp.getPointC(); else if (distance(evt.getX(), evt.getY(), rrp.getPointB(), rrp.getPointC()) < minDistance) { chooseRod = rrp.getrodL2(); chooseRodPoint1 = rrp.getPointB(); chooseRodPoint2 = rrp.getPointC(); } break; default: break; } } repaint(); } else this.setCursor(Cursor.getDefaultCursor()); }
From source file:savant.view.swing.GraphPane.java
/** * {@inheritDoc}//from www . j a va2 s . co m */ @Override public void mouseDragged(MouseEvent event) { setMouseModifier(event); GraphPaneController gpc = GraphPaneController.getInstance(); int x2 = getConstrainedX(event); isDragging = true; if (gpc.isPanning()) { setCursor(new Cursor(Cursor.HAND_CURSOR)); } else if (gpc.isZooming() || gpc.isSelecting()) { setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); } // Check if scrollbar is present (only vertical pan if present) JScrollBar scroller = getVerticalScrollBar(); boolean scroll = scroller.isVisible(); if (scroll) { //get new points Point l = event.getLocationOnScreen(); int currX = l.x; int currY = l.y; //magnitude int magX = Math.abs(currX - startX); int magY = Math.abs(currY - startY); if (magX >= magY) { //pan horizontally, reset vertical pan panVert = false; gpc.setMouseReleasePosition(transformXPixel(x2)); scroller.setValue(initialScroll); } else { //pan vertically, reset horizontal pan panVert = true; gpc.setMouseReleasePosition(baseX); scroller.setValue(initialScroll - (currY - startY)); } } else { //pan horizontally panVert = false; gpc.setMouseReleasePosition(transformXPixel(x2)); } }
From source file:org.omegat.gui.align.AlignPanelController.java
/** * Ensure that the panel controls and available menu items are synced with the settings of the underlying * aligner./*from w ww . j av a 2 s . c o m*/ * * @param panel * @param frame */ private void updatePanel() { panel.comparisonComboBox.setSelectedItem(aligner.comparisonMode); panel.algorithmComboBox.setSelectedItem(aligner.algorithmClass); panel.calculatorComboBox.setSelectedItem(aligner.calculatorType); panel.counterComboBox.setSelectedItem(aligner.counterType); panel.segmentingCheckBox.setSelected(aligner.segment); frame.segmentingItem.setSelected(aligner.segment); panel.segmentingRulesButton.setEnabled(aligner.segment); frame.segmentingRulesItem.setEnabled(aligner.segment); panel.removeTagsCheckBox.setSelected(aligner.removeTags); frame.removeTagsItem.setSelected(aligner.removeTags); panel.advancedPanel.setVisible(phase == Phase.ALIGN); panel.segmentationControlsPanel.setVisible(phase == Phase.ALIGN); panel.filteringControlsPanel.setVisible(phase == Phase.ALIGN); panel.continueButton.setVisible(phase == Phase.ALIGN); panel.controlsPanel.setVisible(phase != Phase.ALIGN); panel.controlsPanel.setEnabled(phase == Phase.EDIT); panel.saveButton.setVisible(phase != Phase.ALIGN); panel.saveButton.setEnabled(phase == Phase.EDIT); String instructions = null; switch (phase) { case ALIGN: instructions = OStrings.getString("ALIGNER_PANEL_ALIGN_PHASE_HELP"); break; case EDIT: instructions = OStrings.getString("ALIGNER_PANEL_EDIT_PHASE_HELP"); break; case PINPOINT: instructions = OStrings.getString("ALIGNER_PANEL_PINPOINT_PHASE_HELP"); } panel.instructionsLabel.setText(instructions); frame.editMenu.setEnabled(phase != Phase.ALIGN); for (Component c : frame.editMenu.getComponents()) { // Batch-enable/disable Edit menu items here, then override later if necessary c.setEnabled(phase == Phase.EDIT); } frame.optionsMenu.setEnabled(phase == Phase.ALIGN); frame.saveItem.setEnabled(phase == Phase.EDIT); panel.table.setCursor(Cursor .getPredefinedCursor(phase == Phase.PINPOINT ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR)); frame.pinpointAlignStartItem.setVisible(phase != Phase.PINPOINT); frame.pinpointAlignEndItem.setVisible(phase == Phase.PINPOINT); // frame.pinpointAlign[Start|End]Item enabledness depends on table selection frame.pinpointAlignCancelItem.setVisible(phase == Phase.PINPOINT); frame.pinpointAlignCancelItem.setEnabled(phase == Phase.PINPOINT); JButton defaultButton = phase == Phase.ALIGN ? panel.continueButton : phase == Phase.EDIT ? panel.saveButton : null; frame.getRootPane().setDefaultButton(defaultButton); updateCommandAvailability(panel, frame); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { resizeRows(panel.table); } }); }
From source file:ded.ui.DiagramController.java
/** Change the UI mode to 'm', maintaining a few invariants in the process. */ public void setMode(Mode m) { this.mode = m; if (m != Mode.DCM_DRAGGING) { if (this.dragging != null) { this.dragging.stopDragging(); }//from ww w. j a v a2 s . c o m this.dragging = null; this.dragOffset = new Point(0, 0); } if (m != Mode.DCM_RECT_LASSO) { this.lassoStart = this.lassoEnd = new Point(0, 0); this.lassoOriginalSelected.clear(); } switch (m) { default: // I tried crosshair for lasso, but that is too annoying // when just clicking in empty space. I also tried the // "move" cursor for dragging, but that cursor blocks too // much of the view of the area right under what is being // moved, making precise positioning difficult. // // Basically, I don't really need a different cursor when // the mouse button is pressed because the user has already // initiated an action and is therefore aware that something // unusual is happening. And in most other cases, I don't // need a special cursor because the effect of pressing the // mouse is fairly obvious already. this.setCursor(Cursor.getDefaultCursor()); break; case DCM_CREATE_ENTITY: case DCM_CREATE_INHERITANCE: case DCM_CREATE_RELATION: // The crosshair here is not particularly suggestive of // what the mode does, but it is noticeably different, // which clues the user to the altered behavior. this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); break; } this.selfCheck(); this.repaint(); }
From source file:org.earthtime.UPb_Redux.dateInterpretation.WeightedMeanGraphPanel.java
/** * * @param imageMode//from ww w .java2 s. com */ public void setImageMode(String imageMode) { this.imageMode = imageMode; if (imageMode.equalsIgnoreCase("PAN")) { weightedMeanCursor = new Cursor((Cursor.HAND_CURSOR)); } else if (imageMode.equalsIgnoreCase("ZOOM")) { weightedMeanCursor = new Cursor((Cursor.CROSSHAIR_CURSOR)); } // force issue setCursor(weightedMeanCursor); }