Tabnine Logo
BezierPath.size
Code IndexAdd Tabnine to your IDE (free)

How to use
size
method
in
org.jhotdraw.geom.BezierPath

Best Java code snippets using org.jhotdraw.geom.BezierPath.size (Showing top 20 results out of 315)

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Gets the node count.
 */
public int getNodeCount() {
  return path.size();
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Returns the point at the center of the bezier path.
 */
public Point2D.Double getCenter() {
  double sx = 0;
  double sy = 0;
  for (Node p : this) {
    sx += p.x[0];
    sy += p.y[0];
  }
  int n = size();
  return new Point2D.Double(sx / n, sy / n);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Tests if there are more points to read.
 * @return true if there are more points to read
 */
@Override
public boolean isDone() {
  return (index >= path.size() + (path.isClosed() ? 2 : 0));
}

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Sets all values of this bezier path to that bezier path, so that this
 * path becomes identical to that path.
 */
public void setTo(BezierPath that) {
  while (that.size() < size()) {
    remove(size() - 1);
  }
  for (int i = 0, n = size(); i < n; i++) {
    get(i).setTo(that.get(i));
  }
  while (size() < that.size()) {
    add((Node) that.get(size()).clone());
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Finds a control point index.
 * Returns -1 if no control point could be found.
 * FIXME - Move this to BezierPath
 */
public int findNode(Point2D.Double p) {
  BezierPath tp = path;
  for (int i = 0; i < tp.size(); i++) {
    BezierPath.Node p2 = tp.get(i);
    if (p2.x[0] == p.x && p2.y[0] == p.y) {
      return i;
    }
  }
  return -1;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Creates a polygon/polyline array of the bezier path which only includes
 * the C0 control points of the bezier nodes.
 * <p>
 * If the bezier path is closed, the array describes a polygon.
 * If the bezier path is open, the array describes a polyline.
 * <p>
 * @return Point array.
 */
public Point2D.Double[] toPolygonArray() {
  Point2D.Double[] points = new Point2D.Double[size()];
  for (int i = 0, n = size(); i < n; i++) {
    points[i] = new Point2D.Double(get(i).x[0], get(i).y[0]);
  }
  return points;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Fits a bezier path to the specified list of digitized points.
 * <p>
 * This is a convenience method for calling fitCubicSegments(List<Point2D.Double>, double);
 * 
 * @param digitizedPoints digited points.
 * @param error the maximal allowed error between the bezier path and the
 * digitized points. 
 */
public static BezierPath fitBezierPath(BezierPath digitizedPoints, double error) {
  ArrayList<Point2D.Double> d = new ArrayList<Point2D.Double>(digitizedPoints.size());
  for (BezierPath.Node n : digitizedPoints) {
    d.add(new Point2D.Double(n.x[0], n.y[0]));
  }
  return fitBezierPath(d, error);
}
origin: net.imagej/imagej-ui-swing

@Override
public Collection<Handle> createHandles(final int detailLevel) {
  final LinkedList<Handle> handles = new LinkedList<>();
  if (detailLevel != 0) {
    return super.createHandles(detailLevel);
  }
  handles.add(new BezierOutlineHandle(this));
  for (int i = 0, n = path.size(); i < n; i++) {
    handles.add(new PolygonNodeHandle(this, i));
  }
  return handles;
}
origin: net.imagej/ij-ui-swing

@Override
public Collection<Handle> createHandles(final int detailLevel) {
  final LinkedList<Handle> handles = new LinkedList<Handle>();
  if (detailLevel != 0) {
    return super.createHandles(detailLevel);
  }
  handles.add(new BezierOutlineHandle(this));
  for (int i = 0, n = path.size(); i < n; i++) {
    handles.add(new SwingPolygonNodeHandle(this, i));
  }
  return handles;
}
origin: net.imagej/imagej-ui-swing

@Override
public Collection<Handle> createHandles(final int detailLevel) {
  final LinkedList<Handle> handles = new LinkedList<>();
  if (detailLevel != 0) {
    return super.createHandles(detailLevel);
  }
  handles.add(new BezierOutlineHandle(this));
  for (int i = 0, n = path.size(); i < n; i++) {
    handles.add(new PolygonNodeHandle(this, i));
  }
  return handles;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public Collection<Handle> createHandles(SVGPathFigure pathFigure, int detailLevel) {
  LinkedList<Handle> handles = new LinkedList<Handle>();
  switch (detailLevel % 2) {
    case 0:
      for (int i = 0, n = path.size(); i < n; i++) {
        handles.add(new BezierNodeHandle(this, i, pathFigure));
      }
      break;
    case 1:
      TransformHandleKit.addTransformHandles(this, handles);
      break;
    default:
      break;
  }
  return handles;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public Collection<Handle> createHandles(ODGPathFigure pathFigure, int detailLevel) {
  LinkedList<Handle> handles = new LinkedList<Handle>();
  switch (detailLevel % 2) {
    case 0:
      for (int i = 0, n = path.size(); i < n; i++) {
        handles.add(new BezierNodeHandle(this, i, pathFigure));
      }
      break;
    case 1:
      TransformHandleKit.addTransformHandles(this, handles);
      break;
    default:
      break;
  }
  return handles;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

  @Override
  public Collection<Handle> createHandles(int detailLevel) {
    LinkedList<Handle> handles = new LinkedList<Handle>();
    switch (detailLevel) {
      case -1 : // Mouse hover handles
        handles.add(new BezierOutlineHandle(this, true));
        break;
      case 0 :
        handles.add(new BezierOutlineHandle(this));
        for (int i=0, n = path.size(); i < n; i++) {
          handles.add(new BezierNodeHandle(this, i));
        }
        break;
    }
    return handles;
  }
// CONNECTING
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/** Creates a deep copy of the BezierPath. */
@Override
public BezierPath clone() {
  BezierPath that = (BezierPath) super.clone();
  for (int i = 0, n = this.size(); i < n; i++) {
    that.set(i, (Node) this.get(i).clone());
  }
  return that;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Adds a (at least) linear 'curve' to the bezier path.
 * <p>
 * If the previous node has no C2 control point the line will be straight
 * (linear), otherwise the line will be quadratic.
 * <p>
 * This is a convenience method for adding a node with a single control
 * point C0.
 * <p>
 * The bezier path must already have at least one node.
 */
public void lineTo(double x1, double y1) {
  if (size() == 0) {
    throw new IllegalPathStateException("lineTo only allowed when not empty");
  }
  get(size() - 1).keepColinear = false;
  add(new Node(x1, y1));
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public Collection<Handle> createHandles(int detailLevel) {
  LinkedList<Handle> handles = new LinkedList<Handle>();
  switch (detailLevel % 2) {
    case -1: // Mouse hover handles
      handles.add(new BezierOutlineHandle(this, true));
      break;
    case 0:
      handles.add(new BezierOutlineHandle(this));
      for (int i = 0, n = path.size(); i < n; i++) {
        handles.add(new BezierNodeHandle(this, i));
      }
      break;
    case 1:
      TransformHandleKit.addTransformHandles(this, handles);
      handles.add(new BezierScaleHandle(this));
      break;
  }
  return handles;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Adds the first node to the bezier path.
 * <p>
 * This is a convenience method for adding the first node with a single
 * control point C0 to the bezier path.
 */
public void moveTo(double x1, double y1) {
  if (size() != 0) {
    throw new IllegalPathStateException("moveTo only allowed when empty");
  }
  Node node = new Node(x1, y1);
  node.keepColinear = false;
  add(node);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Joins two segments into one if the given Point2D.Double hits a node
 * of the bezier path.
 * @return the index of the joined segment or -1 if no segment was joined.
 */
public int joinSegments(Point2D.Double join, double tolerance) {
  for (int i = 0; i < size(); i++) {
    Node p = get(i);
    if (Geom.length(p.x[0], p.y[0], join.x, join.y) < tolerance) {
      remove(i);
      return i;
    }
  }
  return -1;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Adds a (at least) quadratic curve to the bezier path.
 * <p>
 * If the previous node has no C2 control point the line will be quadratic
 * otherwise the line will be cubic.
 * <p>
 * This is a convenience method for adding a node with control point C0 and
 * C1 (incoming curve) to the bezier path.
 * <p>
 * The bezier path must already have at least one node.
 */
public void quadTo(double x1, double y1,
    double x2, double y2) {
  if (size() == 0) {
    throw new IllegalPathStateException("quadTo only allowed when not empty");
  }
  add(new Node(C1_MASK, x2, y2, x1, y1, x2, y2));
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Adds the curve to the bezier path.
 * 
 * @param bezCurve
 * @param bezierPath
 */
private static void addCurveTo(Point2D.Double[] bezCurve, BezierPath bezierPath, double errorSquared, boolean connectsCorners) {
  BezierPath.Node lastNode = bezierPath.get(bezierPath.size() - 1);
  double error = Math.sqrt(errorSquared);
  if (connectsCorners && Geom.lineContainsPoint(lastNode.x[0], lastNode.y[0], bezCurve[3].x, bezCurve[3].y, bezCurve[1].x, bezCurve[1].y, error) &&
      Geom.lineContainsPoint(lastNode.x[0], lastNode.y[0], bezCurve[3].x, bezCurve[3].y, bezCurve[2].x, bezCurve[2].y, error)) {
    bezierPath.lineTo(
        bezCurve[3].x, bezCurve[3].y);
  } else {
    bezierPath.curveTo(
        bezCurve[1].x, bezCurve[1].y,
        bezCurve[2].x, bezCurve[2].y,
        bezCurve[3].x, bezCurve[3].y);
  }
}
org.jhotdraw.geomBezierPathsize

Popular methods of BezierPath

  • <init>
    Creates a new instance.
  • curveTo
    Adds a cubic curve to the bezier path. This is a convenience method for adding a node with control p
  • lineTo
    Adds a (at least) linear 'curve' to the bezier path. If the previous node has no C2 control point th
  • moveTo
    Adds the first node to the bezier path. This is a convenience method for adding the first node with
  • quadTo
    Adds a (at least) quadratic curve to the bezier path. If the previous node has no C2 control point t
  • setClosed
  • transform
    Transforms the BezierPath.
  • toGeneralPath
    Converts the BezierPath into a Path2D.Double.
  • add
  • addAll
  • addPolyline
    Adds a set of nodes to the path. Convenience method for adding multiple nodes with a single control
  • arcTo
    Adds an elliptical arc, defined by two radii, an angle from the x-axis, a flag to choose the large a
  • addPolyline,
  • arcTo,
  • chop,
  • clear,
  • clone,
  • contains,
  • findSegment,
  • get,
  • getBounds2D

Popular in Java

  • Running tasks concurrently on multiple threads
  • getResourceAsStream (ClassLoader)
  • requestLocationUpdates (LocationManager)
  • getExternalFilesDir (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now