List of usage examples for java.awt Rectangle getCenterX
public double getCenterX()
From source file:ru.runa.wfe.graph.image.figure.AbstractFigure.java
protected AngleInfo getTransitionAngle(double x, double y) { Rectangle rect = getRectangle(); double cx = rect.getCenterX(); double cy = rect.getCenterY(); if (x == cx) { return y - cy > 0 ? new AngleInfo(Double.MAX_VALUE, AngleInfo.QUARTER_IV) : new AngleInfo(Double.MAX_VALUE, AngleInfo.QUARTER_II); } else {// w w w .jav a2 s. com double critAngle = rect.getHeight() / rect.getWidth(); AngleInfo angleInfo = new AngleInfo(); angleInfo.setAngle((y - cy) / (x - cx)); if (Math.abs(angleInfo.getAngle()) > critAngle) { if (y - cy > 0) { // IV angleInfo.setQuarter(AngleInfo.QUARTER_IV); } else { // II angleInfo.setQuarter(AngleInfo.QUARTER_II); } } else { if (x - cx > 0) { // I angleInfo.setQuarter(AngleInfo.QUARTER_I); } else { // III angleInfo.setQuarter(AngleInfo.QUARTER_III); } } return angleInfo; } }
From source file:ru.runa.wfe.graph.image.figure.AbstractFigure.java
public Point getTransitionPoint(Transition transition, double x, double y) { AngleInfo angle = getTransitionAngle(x, y); Rectangle r = getRectangle(); double cx = r.getCenterX(); double cy = r.getCenterY(); Line line1 = createBorderLine(angle); Line line2 = LineUtils.createLine(new Point((int) cx, (int) cy), angle.getAngle()); Point intersectionPoint = LineUtils.getIntersectionPoint(line1, line2); return intersectionPoint; }