public void setGeometryByValue(Line ln) throws ObjectStreamException { try { attribs = null; if (ln == null) { descriptionBitMask = -1; } VertexDescription vd = ln.getDescription(); descriptionBitMask = vd.m_semanticsBitArray; attribs = new double[vd.getTotalComponentCount() * 2]; attribs[0] = ln.getStartX(); attribs[1] = ln.getStartY(); attribs[2] = ln.getEndX(); attribs[3] = ln.getEndY(); int index = 4; for (int i = 1, n = vd.getAttributeCount(); i < n; i++) { int semantics = vd.getSemantics(i); int comps = VertexDescription.getComponentCount(semantics); for (int ord = 0; ord < comps; ord++) { attribs[index++] = ln.getStartAttributeAsDbl(semantics, ord); attribs[index++] = ln.getEndAttributeAsDbl(semantics, ord); } } } catch (Exception ex) { throw new InvalidObjectException("Cannot serialize this geometry"); } } }
for(Line line : lines){ writer.append(line.getItemNo()).append(","); writer.append(line.getDescription()).append(","); ... writer.append("\n"); }
int compareHorizontal2_(Line line_1, Line line_2) { if (line_1.getEndY() == line_2.getEndY() && line_1.getEndX() == line_2.getEndX() && line_1.getStartY() == line_2.getStartY() && line_1.getStartX() == line_2.getStartX()) {// both lines // coincide if (m_b_is_simple) return errorCoincident(); return 0; } else return errorCracking(); }
for (Data<X, Y> horizontalMarker : horizontalMarkers) { Line line = (Line) horizontalMarker.getNode(); line.setStartX(0); line.setEndX(getBoundsInLocal().getWidth()); line.setStartY(getYAxis().getDisplayPosition(horizontalMarker.getYValue()) + 0.5); // 0.5 for crispness line.setEndY(line.getStartY()); line.toFront(); Node text = nodeMap.get(line); text.relocate(line.getBoundsInParent().getMinX() + line.getBoundsInParent().getWidth()/2 - text.prefWidth(-1) / 2, line.getBoundsInParent().getMinY() - 30); }
int compareNonHorizontalUpperEnd_(SimpleEdge line_1, SimpleEdge line_2) { int sign = 1; if (line_2.m_line.getEndY() < line_1.m_line.getEndY()) { sign = -1; SimpleEdge tmp = line_1; line_1 = line_2; line_2 = tmp; } Line l1 = line_1.m_line; Line l2 = line_2.m_line; // Now line_1 has End point lower than line_2 endpoint. double x_1 = l1.getEndX() - l2.getStartX(); double x2 = line_2.m_dxdy * (l1.getEndY() - l2.getStartY()); double tol = m_tolerance_10; if (x_1 < x2 - tol) return -sign; else if (x_1 > x2 + tol) return sign; else // Possible problem { if (l2._isIntersectingPoint(l1.getEndXY(), m_tolerance, true)) return errorCracking(); return x_1 < x2 ? -sign : sign; } }
m_helper_line_1 = new Line(); m_helper_line_2 = new Line(); m_helper_line_1.setStartXY(command.m_from); m_helper_line_1.setEndXY(command.m_to); m_helper_line_2.setStartXY(command_next.m_from); m_helper_line_2.setEndXY(command_next.m_to); int count_ = m_helper_line_1.intersect(m_helper_line_2, m_helper_array, null, null, m_small_tolerance); if (count_ == 1) {
pane.setOnMouseDragged(e -> { if (currentDraggingLine != null) { currentDraggingLine.setEndX(e.getX()); currentDraggingLine.setEndY(e.getY()); currentDraggingLine.setEndX(e.getX()); currentDraggingLine.setEndY(e.getY()); Point2D line1Start = new Point2D(line1.getStartX(), line1.getStartY()); Point2D line1End = new Point2D(line1.getEndX(), line1.getEndY()); Point2D line2Start = new Point2D(line2.getStartX(), line2.getStartY()); Point2D line2End = new Point2D(line2.getEndX(), line2.getEndY());
if (!bCurve) { m_shape.queryLineConnector(vertex, m_line_1); m_env.setCoordsNoNaN_(m_line_1.getStartX(), m_line_1.getEndX()); return 1; if (m_line_1.getStartY() == m_line_1.getEndY()) { m_current_node = node; m_b_intersection_detected = true; m_line_1.orientBottomUp_(); Point2D start = m_line_1.getStartXY(); Point2D vector = new Point2D(); vector.sub(m_line_1.getEndXY(), start); vector.rightPerpendicular(); Point2D v_2 = new Point2D(); return 1; if (m_line_1.isIntersecting(m_point_of_interest, m_tolerance)) { double absDot = Math.abs(dot); if (absDot < m_min_dist) {
double dx = tx - x; double dy = ty - y; l.setStartX( l.getStartX() + dx ); l.setStartY( l.getStartY() + dy ); l.setEndX( l.getEndX() + dx ); l.setEndY( l.getEndY() + dy ); x = tx; y = ty; l.setStroke( Color.RED ); } else if( e.getEventType() == MouseEvent.MOUSE_EXITED ) { l.setStroke( Color.BLACK );
private static Geom makeLine(Geom... geoms) { final Polyline g = new Polyline(); Point p = null; for (Geom geom : geoms) { if (geom.g() instanceof Point) { final Point prev = p; p = (Point) geom.g(); if (prev != null) { final Line line = new Line(); line.setStart(prev); line.setEnd(p); g.addSegment(line, false); } } } return new SimpleGeom(g); }
boolean queryLineConnector(int vertex, Line line) { int next = getNextVertex(vertex); if (next == -1) return false; if (!m_b_has_attributes) { Point2D pt = new Point2D(); getXY(vertex, pt); line.setStartXY(pt); getXY(next, pt); line.setEndXY(pt); } else { Point pt = new Point(); queryPoint(vertex, pt); line.setStart(pt); queryPoint(next, pt); line.setEnd(pt); } return true; }
public Object readResolve() throws ObjectStreamException { Line ln = null; if (descriptionBitMask == -1) return null; try { VertexDescription vd = VertexDescriptionDesignerImpl .getVertexDescription(descriptionBitMask); ln = new Line(vd); if (attribs != null) { ln.setStartXY(attribs[0], attribs[1]); ln.setEndXY(attribs[2], attribs[3]); int index = 4; for (int i = 1, n = vd.getAttributeCount(); i < n; i++) { int semantics = vd.getSemantics(i); int comps = VertexDescription.getComponentCount(semantics); for (int ord = 0; ord < comps; ord++) { ln.setStartAttribute(semantics, ord, attribs[index++]); ln.setEndAttribute(semantics, ord, attribs[index++]); } } } } catch (Exception ex) { throw new InvalidObjectException("Cannot read geometry from stream"); } return ln; }
int compareNonHorizontalLowerEnd_(SimpleEdge line_1, SimpleEdge line_2) { int sign = 1; if (line_1.m_line.getStartY() < line_2.m_line.getStartY()) { sign = -1; SimpleEdge tmp = line_1; line_1 = line_2; line_2 = tmp; } Line l1 = line_1.m_line; Line l2 = line_2.m_line; // Now line_1 has Start point higher than line_2 startpoint. double x_1 = l1.getStartX() - l2.getStartX(); double x2 = line_2.m_dxdy * (l1.getStartY() - l2.getStartY()); double tol = m_tolerance_10; if (x_1 < x2 - tol) return -sign; else if (x_1 > x2 + tol) return sign; else // Possible problem { if (l2._isIntersectingPoint(l1.getStartXY(), m_tolerance, true)) return errorCracking(); return x_1 < x2 ? -sign : sign; } }
private boolean crackBruteForce_() { EditShape.VertexIterator iter_1 = m_shape.queryVertexIterator(false); boolean b_cracked = false; Line line_1 = new Line(); Line line_2 = new Line(); Envelope2D seg_1_env = new Envelope2D(); seg_1_env.setEmpty(); continue; seg_1 = line_1; line_1.queryEnvelope2D(seg_1_env); } else seg_1.queryEnvelope2D(seg_1_env);
int compareHorizontal2_(Line line_1, Line line_2) { if (line_1.getEndY() == line_2.getEndY() && line_1.getEndX() == line_2.getEndX() && line_1.getStartY() == line_2.getStartY() && line_1.getStartX() == line_2.getStartX()) {// both lines // coincide if (m_b_is_simple) return errorCoincident(); return 0; } else return errorCracking(); }
int compareNonHorizontalUpperEnd_(SimpleEdge line_1, SimpleEdge line_2) { int sign = 1; if (line_2.m_line.getEndY() < line_1.m_line.getEndY()) { sign = -1; SimpleEdge tmp = line_1; line_1 = line_2; line_2 = tmp; } Line l1 = line_1.m_line; Line l2 = line_2.m_line; // Now line_1 has End point lower than line_2 endpoint. double x_1 = l1.getEndX() - l2.getStartX(); double x2 = line_2.m_dxdy * (l1.getEndY() - l2.getStartY()); double tol = m_tolerance_10; if (x_1 < x2 - tol) return -sign; else if (x_1 > x2 + tol) return sign; else // Possible problem { if (l2._isIntersectingPoint(l1.getEndXY(), m_tolerance, true)) return errorCracking(); return x_1 < x2 ? -sign : sign; } }
m_helper_line_1 = new Line(); m_helper_line_2 = new Line(); m_helper_line_1.setStartXY(command.m_from); m_helper_line_1.setEndXY(command.m_to); m_helper_line_2.setStartXY(command_next.m_from); m_helper_line_2.setEndXY(command_next.m_to); int count_ = m_helper_line_1.intersect(m_helper_line_2, m_helper_array, null, null, m_small_tolerance); if (count_ == 1) {
if (!bCurve) { m_shape.queryLineConnector(vertex, m_line_1); m_env.setCoordsNoNaN_(m_line_1.getStartX(), m_line_1.getEndX()); return 1; if (m_line_1.getStartY() == m_line_1.getEndY()) { m_current_node = node; m_b_intersection_detected = true; m_line_1.orientBottomUp_(); Point2D start = m_line_1.getStartXY(); Point2D vector = new Point2D(); vector.sub(m_line_1.getEndXY(), start); vector.rightPerpendicular(); Point2D v_2 = new Point2D(); return 1; if (m_line_1.isIntersecting(m_point_of_interest, m_tolerance)) { double absDot = Math.abs(dot); if (absDot < m_min_dist) {