Java Code Examples for java.awt.Point#getY()

The following examples show how to use java.awt.Point#getY() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
@Nullable
public AbstractElement findForPoint(@Nullable final Point point) {
  AbstractElement result = null;
  if (point != null) {
    if (this.bounds.contains(point.getX(), point.getY()) || this.collapsatorZone.contains(point.getX() - this.bounds.getX(), point.getY() - this.bounds.getY())) {
      result = this;
    } else if (!isCollapsed()) {
      final double topZoneY = this.bounds.getY() - (this.blockSize.getHeight() - this.bounds.getHeight()) / 2;
      final double topZoneX = isLeftDirection() ? this.bounds.getMaxX() - this.blockSize.getWidth() : this.bounds.getX();

      if (point.getX() >= topZoneX && point.getY() >= topZoneY && point.getX() < (this.blockSize.getWidth() + topZoneX) && point.getY() < (this.blockSize.getHeight() + topZoneY)) {
        for (final Topic t : this.model.getChildren()) {
          final AbstractElement w = (AbstractElement) t.getPayload();
          result = w == null ? null : w.findForPoint(point);
          if (result != null) {
            break;
          }
        }
      }
    }
  }
  return result;
}
 
Example 2
Source Project: netbeans   File: ComponentPeer.java    License: Apache License 2.0 6 votes vote down vote up
private int[] computeVisibleSpan() {
    Component parent = pane.getParent();
    
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }

    if (parent instanceof JViewport) {
        JViewport vp = (JViewport) parent;

        Point start = vp.getViewPosition();
        Dimension size = vp.getExtentSize();
        Point end = new Point((int) (start.getX() + size.getWidth()), (int) (start.getY() + size.getHeight()));

        int startPosition = pane.viewToModel(start);
        int endPosition = pane.viewToModel(end);

        if (parentWithListener != vp) {
            vp.addChangeListener(WeakListeners.change(this, vp));
            parentWithListener = vp;
        }
        return new int[] {startPosition, endPosition};
    }

    return new int[] {0, pane.getDocument().getLength()};
}
 
Example 3
Source Project: chipster   File: MicroarrayGraph.java    License: MIT License 6 votes vote down vote up
private GroupVertex createGroup(GraphVertex[] children) {
	if (children.length < 1) {
		throw new IllegalArgumentException("vertex list is empty");
	}

	// Gets children bounds so group cell can be positioned to upper left corner
	Rectangle2D bounds = this.getCellBounds(children);
	Point p = new Point((int) bounds.getX(), (int) bounds.getY());
	// Point p = layoutManager.getNewRootPosition();

	GroupVertex group = new GroupVertex((int) p.getX(), (int) p.getY(), children, this);
	this.getGraphLayoutCache().insertGroup(group, children);

	group.collapse();

	groups.add(group);

	return group;
}
 
Example 4
Source Project: PIPE   File: SelectionManagerTest.java    License: MIT License 5 votes vote down vote up
@Test
public void selectsUsingLocationOnMousePress() {
    MouseEvent e = mock(MouseEvent.class);
    when(e.getButton()).thenReturn(MouseEvent.BUTTON1);
    when(e.isControlDown()).thenReturn(false);

    Point clickPoint = new Point(50, 50);
    when(e.getPoint()).thenReturn(clickPoint);
    manager.mousePressed(e);

    int x = (int) clickPoint.getX();
    int y = (int) clickPoint.getY();
    Rectangle rect = new Rectangle(x, y, 0, 0);
    verify(mockController).select(rect);
}
 
Example 5
@Override
protected boolean dropNow(WorkflowAnnotation anno, Point loc) {
	if (anno == null) {
		return false;
	}
	AnnotationsModel annoModel = RapidMinerGUI.getMainFrame().getProcessPanel().getAnnotationsHandler().getModel();

	// pasting an operator anno will always create a process anno
	if (loc == null) {
		loc = model.getMousePositionRelativeToProcess();
	}

	int index = model.getHoveringProcessIndex();
	ExecutionUnit targetProcess;
	if (index != -1) {
		targetProcess = model.getProcess(index);
	} else {
		targetProcess = anno.getProcess();
	}

	ProcessAnnotation proAnno = anno.createProcessAnnotation(targetProcess);
	// move to drop location
	Rectangle2D frame = proAnno.getLocation();
	Rectangle2D newFrame = new Rectangle2D.Double(loc.getX(), loc.getY(), frame.getWidth(), frame.getHeight());
	proAnno.setLocation(newFrame);
	annoModel.addProcessAnnotation(proAnno);

	return true;
}
 
Example 6
private void layoutCirculary(Collection<GraphNode<I>> nodes, GraphNode<I> masterNode) {
    Point masterPoint = new Point();
    NodeWidget master = getWidget(masterNode);
    masterPoint.setLocation(master.locX, master.locY);
    double r;
    double theta;
    double thetaStep = Math.PI / 5;
    r = 150;
    theta = 0;
    Iterator<GraphNode<I>> it = nodes.iterator();
    NodeWidget nw = getWidget(it.next());
    while (true) {
        AffineTransform tr = AffineTransform.getRotateInstance(theta);
        Point2D d2point = tr.transform(new Point2D.Double(0, r), null);
        Point point = new Point((int)d2point.getX() + masterPoint.x, (int)d2point.getY() + masterPoint.y);
        if (isThereFreeSpace(point, nw)) {
            nw.locX = point.getX();
            nw.locY = point.getY();
            nw.dispX = 0;
            nw.dispY = 0;
            if (it.hasNext()) {
                nw = getWidget(it.next());
            } else {
                return;
            }
        }
        theta = theta + thetaStep;
        if (theta > (Math.PI * 2 - Math.PI / 10)) {
            r = r + 90;
            theta = theta - Math.PI * 2;
            thetaStep = thetaStep * 3 / 4; 
        }
    }
    
}
 
Example 7
/**
 * Start scrolling.
 */
private void scrollNow() {
	if (mouseOnScreenPoint != null && target.isShowing()) {
		Point origin = target.getLocationOnScreen();
		Point relative = new Point(mouseOnScreenPoint.x - origin.x, mouseOnScreenPoint.y - origin.y);

		Rectangle visibleRect = target.getVisibleRect();

		if (!visibleRect.contains(relative)) {
			int destX = relative.x;
			if (relative.getX() < visibleRect.getMinX()) {
				destX = (int) visibleRect.getMinX() - PAN_STEP_SIZE;
			}
			if (relative.getX() > visibleRect.getMaxX()) {
				destX = (int) visibleRect.getMaxX() + PAN_STEP_SIZE;
			}

			int destY = relative.y;
			if (relative.getY() < visibleRect.getMinY()) {
				destY = (int) visibleRect.getMinY() - PAN_STEP_SIZE;
			}
			if (relative.getY() > visibleRect.getMaxY()) {
				destY = (int) visibleRect.getMaxY() + PAN_STEP_SIZE;
			}

			target.scrollRectToVisible(new Rectangle(new Point(destX, destY)));
		}
	}
}
 
Example 8
Source Project: netbeans   File: CodeFoldingSideBar.java    License: Apache License 2.0 5 votes vote down vote up
private void refreshIfMouseOutside(Point pt) {
    mousePoint = (int)pt.getY();
    if (LOG.isLoggable(Level.FINEST)) {
        if (mouseBoundary == null) {
            LOG.log(Level.FINEST, "Mouse boundary not set, refreshing: {0}", mousePoint);
        } else {
            LOG.log(Level.FINEST, "Mouse {0} inside known mouse boundary: {1}-{2}", 
                    new Object[] { mousePoint, mouseBoundary.y, mouseBoundary.getMaxY() });
        }
    }
    if (mouseBoundary == null || mousePoint < mouseBoundary.y || mousePoint > mouseBoundary.getMaxY()) {
        refresh();
    }
}
 
Example 9
/**
 * Converts a pixel position into a mercator position
 * @param p {@Point} object that you wish to convert into
 *        longitude / latiude
 * @return the converted {@code Position} object
 * @since 1.0
 */
public Position toPosition(Point p) {
    double lat, lon;
    Position pos = null;
    try {
        Point pixelCentre = toPixel(new Position(0, 0));

        // Get the distance between position and the centre
        double xDistance = distance(xCentre, p.getX());
        double yDistance = distance(pixelCentre.getY(), p.getY());
        double lonDistanceInDegrees = (xDistance * minutesPerPixel) / 60;
        double mp = (yDistance * minutesPerPixel);
        // If we are zoomed in past a certain point, then use linear search.
        // Otherwise use binary search
        if (getMinutesPerPixel() < 0.05) {
            lat = findLat(mp, getCentre().getLatitude());
            if (lat == -1000) {
                System.out.println("lat: " + lat);
            }
        } else {
            lat = findLat(mp, 0.0, 85.0);
        }
        lon = (p.getX() < xCentre ? centre.getLongitude() - lonDistanceInDegrees
                : centre.getLongitude() + lonDistanceInDegrees);

        if (p.getY() > pixelCentre.getY()) {
            lat = -1 * lat;
        }
        if (lat == -1000 || lon == -1000) {
            return pos;
        }
        pos = new Position(lat, lon);
    } catch (InvalidPositionException ipe) {
        ipe.printStackTrace();
    }
    return pos;
}
 
Example 10
Source Project: FastCopy   File: FastCopyMainForm.java    License: Apache License 2.0 5 votes vote down vote up
public void init() {
	frame = new JFrame("MHISoft FastCopy " + UI.version);
	frame.setContentPane(layoutPanel1);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	//progressBar1.setVisible(false);
	progressBar1.setMaximum(100);
	progressBar1.setMinimum(0);

	progressPanel.setVisible(false);
	//frame.setPreferredSize(new Dimension(1200, 800));
	frame.setPreferredSize(new Dimension(UserPreference.getInstance().getDimensionX(), UserPreference.getInstance().getDimensionY()));

	frame.pack();

	/*position it*/
	//frame.setLocationRelativeTo(null);  // *** this will center your app ***
	PointerInfo a = MouseInfo.getPointerInfo();
	Point b = a.getLocation();
	int x = (int) b.getX();
	int y = (int) b.getY();
	frame.setLocation(x + 100, y);

	btnHelp.setBorder(null);

	frame.setVisible(true);


	componentsList = ViewHelper.getAllComponents(frame);
	setupFontSpinner();
	ViewHelper.setFontSize(componentsList, UserPreference.getInstance().getFontSize());



}
 
Example 11
/**
 * Handles a drag event based on the given {@link Point}.
 *
 * @param point
 *            the new point
 */
public void handleDragEvent(final Point point) {
	WorkflowAnnotation draggedAnno = getDraggedAnnotation();
	double xOffset = point.getX() - getOrigin().getX();
	double yOffset = point.getY() - getOrigin().getY();

	// we set the drag flag even if not yet unsnapped
	if (xOffset != 0 || yOffset != 0) {
		dragStarted = true;
	}

	// operator annotations need to be dragged a certain amount before they come "loose"
	if (dragged instanceof OperatorAnnotation) {
		if (!unsnapped && Math.abs(xOffset) < OPERATOR_ANNOTATION_UNSNAP_DISTANCE
				&& Math.abs(yOffset) < OPERATOR_ANNOTATION_UNSNAP_DISTANCE) {
			return;
		} else {
			unsnapped = true;
		}
	}

	double newX = draggedAnno.getLocation().getX() + xOffset;
	double newY = draggedAnno.getLocation().getY() + yOffset;
	double width = draggedAnno.getLocation().getWidth();
	double height = draggedAnno.getLocation().getHeight();

	// make sure dragging out of process is not allowed
	if (newX < WorkflowAnnotation.MIN_X) {
		newX = WorkflowAnnotation.MIN_X;
	}
	if (newY < WorkflowAnnotation.MIN_Y) {
		newY = WorkflowAnnotation.MIN_Y;
	}

	// check if we are hovering over an operator which does NOT have an annotation
	if (model.getHoveringProcessIndex() != -1) {
		ExecutionUnit process = model.getProcess(model.getHoveringProcessIndex());
		if (process != null) {
			hoveredOperator = null;
			for (Operator op : process.getOperators()) {
				if (model.getOperatorRect(op) != null
						&& model.getOperatorRect(op).contains(model.getMousePositionRelativeToProcess())) {
					if (model.getOperatorAnnotations(op) == null || model.getOperatorAnnotations(op).isEmpty()) {
						hoveredOperator = op;
						break;
					} else if (model.getOperatorAnnotations(op).getAnnotationsDrawOrder().contains(draggedAnno)) {
						// our own origin is a valid target as well
						hoveredOperator = op;
						break;
					}
				}
			}
		}
	}

	Rectangle2D newLoc = new Rectangle2D.Double(newX, newY, width, height);
	draggedAnno.setLocation(newLoc);
	setOrigin(point);
}
 
Example 12
public void mouseClicked(MouseEvent e) {
        	if(world.started()) return;//Если идет обсчет не суетимся, выводить ничего не надо.
        	
        	Point p	= e.getPoint();
        	int x	= (int) p.getX();
        	int y	= (int) p.getY();
        	int botX=(x-2)/BOTW;
        	int botY=(y-2)/BOTH;	
        	Bot bot	= world.getBot(botX,botY);
        	if(bot!=null)
        	{
        		{
        			Graphics g	= buffer.getGraphics();
	        		g.setColor(Color.MAGENTA);
	        		g.fillRect(botX * BOTW, botY * BOTH, BOTW, BOTH);
//                    g.setColor(Color.BLACK);
  //                  g.drawRect(botX * 4, botY * 4, 4, 4);
	                paintPanel.repaint();
	        	}
        		StringBuilder buf	= new StringBuilder();
        		buf.append("<html>");
        		buf.append("<p>Многоклеточный: ");
        		switch(bot.isMulti())
        		{
        			case 0:// - нет,
        				buf.append("нет</p>");
        				break;
        			case 1:// - есть MPREV,
        				buf.append("есть MPREV</p>");
        				break;
        			case 2:// - есть MNEXT,
        				buf.append("есть MNEXT</p>");
        				break;
        			case 3:// есть MPREV и MNEXT
        				buf.append("есть MPREV и MNEXT</p>");
        				break;
        		}
        		buf.append("<p>c_blue="+bot.c_blue);
        		buf.append("<p>c_green="+bot.c_green);
        		buf.append("<p>c_red="+bot.c_red);
        		buf.append("<p>direction="+bot.direction);
        		buf.append("<p>health="+bot.health);
        		buf.append("<p>mineral="+bot.mineral);
        		
        		
        	    //buf.append("");
       	    
        	    IBotGeneController cont;
                for (int i = 0; i < Bot.MIND_SIZE; i++)
                {//15
                    int command = bot.mind[i];  // текущая команда
                    
                    // Получаем обработчика команды
                    cont	= Bot.geneController[command];
                    if(cont!=null)// если обработчик такой команды назначен
                    {
                    	buf.append("<p>");
                    	buf.append(String.valueOf(i));
                    	buf.append("&nbsp;");
                    	buf.append(cont.getDescription(bot, i));
                    	buf.append("</p>");
                    }
                }
        	    
        	    buf.append("</html>");
	        	JComponent component = (JComponent)e.getSource();
	        	//System.out.println(bot);
	        	paintPanel.setToolTipText(buf.toString());
	            MouseEvent phantom = new MouseEvent(
	                    component,
	                    MouseEvent.MOUSE_MOVED,
	                    System.currentTimeMillis()-2000,
	                    0,
	                    x,
	                    y,
	                    0,
	                    false);
	
	            ToolTipManager.sharedInstance().mouseMoved(phantom);
        	}
        
        }
 
Example 13
public void setInitialVelocity(Point initialVelocity) {
    this.initialVelocity = new double[] { initialVelocity.getX(), initialVelocity.getY() };
}
 
Example 14
/**
 * Updates the currently hovered element
 *
 * @param e
 */
private void updateHoveringState(final MouseEvent e) {
	int hoveringProcessIndex = model.getHoveringProcessIndex();
	if (hoveringProcessIndex != -1) {
		ExecutionUnit hoveringProcess = model.getProcess(hoveringProcessIndex);
		Point relativeMousePosition = model.getMousePositionRelativeToProcess();
		int relativeX = (int) relativeMousePosition.getX();
		int relativeY = (int) relativeMousePosition.getY();

		OutputPort connectionSourceUnderMouse = controller.getPortForConnectorNear(relativeMousePosition, hoveringProcess);
		if (connectionSourceUnderMouse != model.getHoveringConnectionSource()) {
			model.setHoveringConnectionSource(connectionSourceUnderMouse);
			model.fireMiscChanged();
			e.consume();
		}

		// find inner sinks/sources under mouse
		if (controller.checkPortUnder(hoveringProcess.getInnerSinks(), relativeX, relativeY)
				|| controller.checkPortUnder(hoveringProcess.getInnerSources(), relativeX, relativeY)) {
			e.consume();
			return;
		}

		// find operator under mouse
		List<Operator> operators = hoveringProcess.getOperators();
		List<Operator> selectedOperators = model.getSelectedOperators();
		// if there are selected operators, they take precedence
		if (!operators.isEmpty() && !selectedOperators.isEmpty()) {
			operators = new ArrayList<>(operators);
			operators.sort((o1, o2) -> {
				int index1 = selectedOperators.indexOf(o1);
				int index2 = selectedOperators.indexOf(o2);
				if (index1 == index2) {
					return 0;
				}
				if (index1 == -1) {
					return -1;
				}
				if (index2 == -1) {
					return 1;
				}
				return index2 - index1;
			});
		}

		ListIterator<Operator> iterator = operators.listIterator(operators.size());
		while (iterator.hasPrevious()) {
			Operator op = iterator.previous();
			// first, check whether we are over a port
			if (controller.checkPortUnder(op.getInputPorts(), relativeX, relativeY)
					|| controller.checkPortUnder(op.getOutputPorts(), relativeX, relativeY)) {
				e.consume();
				return;
			}
			// If not, check operator.
			Rectangle2D rect = model.getOperatorRect(op);
			if (rect == null) {
				continue;
			}
			if (rect.contains(relativeMousePosition)) {
				if (model.getHoveringOperator() != op) {
					model.setHoveringPort(null);
					view.setHoveringOperator(op);
					if (model.getConnectingPortSource() == null) {
						if (model.getHoveringOperator() instanceof OperatorChain) {
							controller.showStatus(I18N.getGUILabel("processRenderer.displayChain.hover"));
						} else {
							controller.showStatus(I18N.getGUILabel("processRenderer.operator.hover"));
						}
					} else {
						controller.showStatus(I18N.getGUILabel("processRenderer.connection.hover_cancel"));
					}
				}
				view.updateCursor();
				e.consume();
				return;
			}
		}
	}
	if (model.getHoveringOperator() != null) {
		view.setHoveringOperator(null);
	}
	if (model.getHoveringPort() != null) {
		model.setHoveringPort(null);
		view.updateCursor();
		model.fireMiscChanged();
	}
	if (model.getHoveringConnectionSource() != null && model.getConnectingPortSource() == null) {
		controller.showStatus(I18N.getGUILabel("processRenderer.connection.hover"));
	} else if (model.getConnectingPortSource() != null) {
		controller.showStatus(I18N.getGUILabel("processRenderer.connection.hover_cancel"));
	} else {
		controller.clearStatus();
	}
}
 
Example 15
@SuppressWarnings("restriction")
public synchronized void confirmSiteLocation(ConstructionSite site, ConstructionManager constructionManager,
		boolean isAtPreDefinedLocation, ConstructionStageInfo stageInfo, int constructionSkill) {
	//System.out.println("ConstructionWizard : entering confirmSiteLocation()");

       // Determine location and facing for the new building.
	double xLoc = site.getXLocation();
	double yLoc = site.getYLocation();
	double scale = mapPanel.getScale();

	Settlement currentS = settlementWindow.getMapPanel().getSettlement();
	if (currentS != constructionManager.getSettlement()) {

		if (mainScene != null) {
			mainScene.setSettlement(constructionManager.getSettlement());
		}
		else {
   			//desktop.openToolWindow(SettlementWindow.NAME);
			settlementWindow.getMapPanel().getSettlementTransparentPanel().getSettlementListBox()
				.setSelectedItem(constructionManager.getSettlement());
		}
	}
 		// set up the Settlement Map Tool to display the suggested location of the building
	mapPanel.reCenter();
	mapPanel.moveCenter(xLoc*scale, yLoc*scale);
	//mapPanel.setShowConstructionLabels(true);
	//mapPanel.getSettlementTransparentPanel().getConstructionLabelMenuItem().setSelected(true);

	String header = null;
	String title = null;
	String message = "(1) Will default to \"Yes\" in 90 secs unless timer is cancelled."
   			+ " (2) To manually place a site, click on \"Use Mouse\" button.";
	StringProperty msg = new SimpleStringProperty(message);
	String name = null;

	if (stageInfo != null) {
		name = stageInfo.getName();
		title = "A New " + Conversion.capitalize(stageInfo.getName()).replace(" X ", " x ") + " at " + constructionManager.getSettlement();
        // stageInfo.getType() is less descriptive than stageInfo.getName()
	}
	else {
		name = site.getName();
		title = "A New " + Conversion.capitalize(site.getName()).replace(" X ", " x ") + " at " + constructionManager.getSettlement();
	}

	if (isAtPreDefinedLocation) {
		header = "Would you like to place the " +  name + " at its default position? ";
	}
	else {
		header = "Would you like to place the " + name + " at this position? ";
	}


       if (mainScene != null) {
       	alertDialog(title, header, msg, constructionManager, site, true, stageInfo, constructionSkill);

	} else {

        desktop.openAnnouncementWindow("Pause for Construction Wizard");
        AnnouncementWindow aw = desktop.getAnnouncementWindow();
        Point location = MouseInfo.getPointerInfo().getLocation();
        double Xloc = location.getX() - aw.getWidth() * 2;
		double Yloc = location.getY() - aw.getHeight() * 2;
		aw.setLocation((int)Xloc, (int)Yloc);

		int reply = JOptionPane.showConfirmDialog(aw, header, TITLE, JOptionPane.YES_NO_OPTION);
		//repaint();

		if (reply == JOptionPane.YES_OPTION) {
            logger.info("The construction site is set");
		}
		else {
			//constructionManager.removeConstructionSite(site);
			//site = new ConstructionSite();
			site = positionNewSite(site);//, constructionSkill);
			confirmSiteLocation(site, constructionManager, false, stageInfo, constructionSkill);
		}

		desktop.disposeAnnouncementWindow();
	}

}
 
Example 16
/**
 * Returns the color at the indicated point in HSB values.
 *
 * @param p a point relative to this panel.
 * @return the HSB values at the point provided.
 */
public float[] getHSB(Point p) {
    if (mode == RED || mode == GREEN ||
            mode == BLUE) {
        int[] rgb = getRGB(p);
        float[] hsb = Color.RGBtoHSB(rgb[0], rgb[1], rgb[2], null);
        return hsb;
    }

    int size = Math.min(MAX_SIZE, Math
            .min(getWidth() - imagePadding.left - imagePadding.right, getHeight() - imagePadding.top - imagePadding.bottom));
    p.translate(-(getWidth() / 2 - size / 2), -(getHeight() / 2 - size / 2));
    if (mode == BRI || mode == SAT) {
        //the two circular views:
        double radius = size / 2.0;
        double x = p.getX() - size / 2.0;
        double y = p.getY() - size / 2.0;
        double r = Math.sqrt(x * x + y * y) / radius;
        double theta = Math.atan2(y, x) / (PI * 2.0);

        if (r > 1) {
            r = 1;
        }

        if (mode == BRI) {
            return new float[]{
                    (float) (theta + 0.25f),
                    (float) r,
                    bri};
        } else {
            return new float[]{
                    (float) (theta + 0.25f),
                    sat,
                    (float) r
            };
        }
    } else {
        float s = ((float) p.x) / ((float) size);
        float b = ((float) p.y) / ((float) size);
        if (s < 0) {
            s = 0;
        }
        if (s > 1) {
            s = 1;
        }
        if (b < 0) {
            b = 0;
        }
        if (b > 1) {
            b = 1;
        }
        return new float[]{hue, s, b};
    }
}
 
Example 17
/**
 * Translates a panel (component) location to a Java2D point.
 *
 * @param screenPoint  the screen location (<code>null</code> not
 *                     permitted).
 *
 * @return The Java2D coordinates.
 */
public Point2D translateScreenToJava2D(Point screenPoint) {
    Insets insets = getInsets();
    double x = (screenPoint.getX() - insets.left) / this.scaleX;
    double y = (screenPoint.getY() - insets.top) / this.scaleY;
    return new Point2D.Double(x, y);
}
 
Example 18
/**
 * Translates a panel (component) location to a Java2D point.
 *
 * @param screenPoint  the screen location (<code>null</code> not
 *                     permitted).
 *
 * @return The Java2D coordinates.
 */
public Point2D translateScreenToJava2D(Point screenPoint) {
    Insets insets = getInsets();
    double x = (screenPoint.getX() - insets.left) / this.scaleX;
    double y = (screenPoint.getY() - insets.top) / this.scaleY;
    return new Point2D.Double(x, y);
}
 
Example 19
Source Project: SIMVA-SoS   File: ChartPanel.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Translates a panel (component) location to a Java2D point.
 *
 * @param screenPoint  the screen location (<code>null</code> not
 *                     permitted).
 *
 * @return The Java2D coordinates.
 */
public Point2D translateScreenToJava2D(Point screenPoint) {
    Insets insets = getInsets();
    double x = (screenPoint.getX() - insets.left) / this.scaleX;
    double y = (screenPoint.getY() - insets.top) / this.scaleY;
    return new Point2D.Double(x, y);
}
 
Example 20
Source Project: PIPE   File: SplitArcAction.java    License: MIT License 2 votes vote down vote up
/**
 *
 * @param arcController arc controller
 * @param mousePoint point at which to split the arc
 */
public SplitArcAction(ArcController<? extends Connectable, ? extends Connectable> arcController, Point mousePoint) {
    this.arcController = arcController;
    point = new Point2D.Double(mousePoint.getX(), mousePoint.getY());
}