Java Code Examples for java.awt.geom.Ellipse2D#contains()
The following examples show how to use
java.awt.geom.Ellipse2D#contains() .
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
Source File: HtmlArea.java From htmlunit with Apache License 2.0 | 6 votes |
/** * Indicates if this area contains the specified point. * @param x the x coordinate of the point * @param y the y coordinate of the point * @return {@code true} if the point is contained in this area */ boolean containsPoint(final int x, final int y) { final String shape = StringUtils.defaultIfEmpty(getShapeAttribute(), SHAPE_RECT).toLowerCase(Locale.ROOT); if ("default".equals(shape) && getCoordsAttribute() != null) { return true; } if (SHAPE_RECT.equals(shape) && getCoordsAttribute() != null) { final Rectangle2D rectangle = parseRect(); return rectangle.contains(x, y); } if (SHAPE_CIRCLE.equals(shape) && getCoordsAttribute() != null) { final Ellipse2D ellipse = parseCircle(); return ellipse.contains(x, y); } if (SHAPE_POLY.equals(shape) && getCoordsAttribute() != null) { final GeneralPath path = parsePoly(); return path.contains(x, y); } return false; }
Example 2
Source File: HtmlArea.java From HtmlUnit-Android with Apache License 2.0 | 6 votes |
/** * Indicates if this area contains the specified point. * @param x the x coordinate of the point * @param y the y coordinate of the point * @return {@code true} if the point is contained in this area */ boolean containsPoint(final int x, final int y) { final String shape = StringUtils.defaultIfEmpty(getShapeAttribute(), "rect").toLowerCase(Locale.ROOT); if ("default".equals(shape) && getCoordsAttribute() != null) { return true; } if ("rect".equals(shape) && getCoordsAttribute() != null) { final Rectangle2D rectangle = parseRect(); return rectangle.contains(x, y); } if ("circle".equals(shape) && getCoordsAttribute() != null) { final Ellipse2D ellipse = parseCircle(); return ellipse.contains(x, y); } if ("poly".equals(shape) && getCoordsAttribute() != null) { final GeneralPath path = parsePoly(); return path.contains(x, y); } return false; }
Example 3
Source File: CurvedPolylineCreationUI.java From pumpernickel with MIT License | 6 votes |
private Selection getSelection(MouseEvent evt) throws NoninvertibleTransformException { ShapeCreationPanel scp = (ShapeCreationPanel) evt.getComponent(); AffineTransform tx = scp.getTransform(); double r = scp.getHandleSize() / 2; Point2D mouseLoc = new Point2D.Float(evt.getX(), evt.getY()); CurvedPolyline[] shapes = getMirror(scp); for (int shapeIndex = 0; shapeIndex < shapes.length; shapeIndex++) { if (scp.getHandlesActive().supports(scp, shapeIndex)) { for (int b = shapes[shapeIndex].getPointCount() - 1; b >= 0; b--) { Point2D p = tx.transform( shapes[shapeIndex].getPoint(b), null); Ellipse2D e = new Ellipse2D.Double(p.getX() - r, p.getY() - r, 2 * r, 2 * r); if (e.contains(mouseLoc)) return new Selection(shapeIndex, b, null); } } } return getSelectedShape(scp, evt.getPoint()); }
Example 4
Source File: CellDetector.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
private double calcOverlap(ImageObject imgObj) { int inOverlap = 0; int allCell = 0; Rectangle boundings = imgObj.getBoundings(); Ellipse2D ellipse = new Ellipse2D.Float(boundings.x, boundings.y, boundings.width, boundings.height); for (int y = boundings.y; y < boundings.y + boundings.getHeight(); ++y) { for (int x = boundings.x; x < boundings.x + boundings.getWidth(); ++x) { boolean isCell = imgObj.getColorFromGlobalCoordinates(x, y) != Color.WHITE.getRGB(); boolean isOnEllipse = ellipse.contains(new Point(x, y)); if (isCell && isOnEllipse) { ++inOverlap; } if (isCell || isOnEllipse) { ++allCell; } } } return (float) inOverlap / (float) allCell; }
Example 5
Source File: BoxContainerPanelUI.java From pumpernickel with MIT License | 5 votes |
protected AbstractHandle getHandle(PlafContext context, MouseEvent e) { Point p = e.getPoint(); for (final Connector connector : context.bcp.getBoxContainer() .getConnectors()) { Point controlPoint = connector.getControlPoint(false); Ellipse2D handleShape = new Ellipse2D.Float(controlPoint.x - handleRadius, controlPoint.y - handleRadius, 2 * handleRadius, 2 * handleRadius); if (handleShape.contains(e.getPoint())) { AbstractHandle handle = new ConnectorHandle(connector, controlPoint, handleShape); handle.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (AbstractHandle.KEY_CENTER.matches(evt)) { connector.setControlPoint((Point) evt.getNewValue()); } } }); return handle; } } if (context.handles != null) { for (int a = 0; a < context.handles.handles.length; a++) { if (context.handles.handles[a].shape.contains(p)) { return context.handles.handles[a]; } } } return null; }
Example 6
Source File: SplineDisplay.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void mouseMoved(MouseEvent e) { Ellipse2D area1 = getDraggableArea(control1); Ellipse2D area2 = getDraggableArea(control2); if (area1.contains(e.getPoint()) || area2.contains(e.getPoint())) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { setCursor(Cursor.getDefaultCursor()); } }
Example 7
Source File: XpGlobesOverlay.java From plugins with GNU General Public License v3.0 | 4 votes |
private void renderProgressCircle(Graphics2D graphics, XpGlobe skillToDraw, int startXp, int goalXp, int x, int y, Rectangle bounds) { double radiusCurrentXp = getSkillProgressRadius(startXp, skillToDraw.getCurrentXp(), goalXp); double radiusToGoalXp = 360; //draw a circle Ellipse2D backgroundCircle = drawEllipse(graphics, x, y); drawSkillImage(graphics, skillToDraw, x, y); Point mouse = client.getMouseCanvasPosition(); int mouseX = mouse.getX() - bounds.x; int mouseY = mouse.getY() - bounds.y; // If mouse is hovering the globe if (backgroundCircle.contains(mouseX, mouseY)) { // Fill a darker overlay circle graphics.setColor(DARK_OVERLAY_COLOR); graphics.fill(backgroundCircle); drawProgressLabel(graphics, skillToDraw, startXp, goalXp, x, y); if (config.enableTooltips()) { drawTooltip(skillToDraw, goalXp); } } graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); drawProgressArc( graphics, x, y, config.xpOrbSize(), config.xpOrbSize(), PROGRESS_RADIUS_REMAINDER, radiusToGoalXp, 5, config.progressOrbOutLineColor() ); drawProgressArc( graphics, x, y, config.xpOrbSize(), config.xpOrbSize(), PROGRESS_RADIUS_START, radiusCurrentXp, config.progressArcStrokeWidth(), config.enableCustomArcColor() ? config.progressArcColor() : SkillColor.find(skillToDraw.getSkill()).getColor()); }
Example 8
Source File: XpGlobesOverlay.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
private void renderProgressCircle(Graphics2D graphics, XpGlobe skillToDraw, int startXp, int goalXp, int x, int y, Rectangle bounds) { double radiusCurrentXp = getSkillProgressRadius(startXp, skillToDraw.getCurrentXp(), goalXp); double radiusToGoalXp = 360; //draw a circle Ellipse2D backgroundCircle = drawEllipse(graphics, x, y); drawSkillImage(graphics, skillToDraw, x, y); Point mouse = client.getMouseCanvasPosition(); int mouseX = mouse.getX() - bounds.x; int mouseY = mouse.getY() - bounds.y; // If mouse is hovering the globe if (backgroundCircle.contains(mouseX, mouseY)) { // Fill a darker overlay circle graphics.setColor(DARK_OVERLAY_COLOR); graphics.fill(backgroundCircle); drawProgressLabel(graphics, skillToDraw, startXp, goalXp, x, y); if (config.enableTooltips()) { drawTooltip(skillToDraw, goalXp); } } graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); drawProgressArc( graphics, x, y, config.xpOrbSize(), config.xpOrbSize(), PROGRESS_RADIUS_REMAINDER, radiusToGoalXp, 5, config.progressOrbOutLineColor() ); drawProgressArc( graphics, x, y, config.xpOrbSize(), config.xpOrbSize(), PROGRESS_RADIUS_START, radiusCurrentXp, config.progressArcStrokeWidth(), config.enableCustomArcColor() ? config.progressArcColor() : SkillColor.find(skillToDraw.getSkill()).getColor()); }