Tabnine Logo
BezierFigure.addNode
Code IndexAdd Tabnine to your IDE (free)

How to use
addNode
method
in
org.jhotdraw.draw.BezierFigure

Best Java code snippets using org.jhotdraw.draw.BezierFigure.addNode (Showing top 11 results out of 315)

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Adds a control point.
 */
public void addNode(BezierPath.Node p) {
  addNode(getNodeCount(), p);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Splits the segment at the given Point2D.Double if a segment was hit.
 * @return the index of the segment or -1 if no segment was hit.
 *
 * @param split a Point on (or near) a line segment on the bezier path
 * @param tolerance a tolerance, tolerance should take into account
 * the line width, plus 2 divided by the zoom factor. 
 */
public int splitSegment(Point2D.Double split, double tolerance) {
  int i = findSegment(split, tolerance);
  if (i != -1) {
    addNode(i + 1, new BezierPath.Node(split));
  }
  return i + 1;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Convenience method for setting the point coordinate of the start point.
 * If the BezierFigure has not at least two nodes, nodes are added
 * to the figure until the BezierFigure has at least two nodes.
 */
public void setStartPoint(Point2D.Double p) {
  // Add two nodes if we haven't at least two nodes
  for (int i = getNodeCount(); i < 2; i++) {
    addNode(0, new BezierPath.Node(p.x, p.y));
  }
  setPoint(0, p);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void redo() throws CannotRedoException {
  super.redo();
  willChange();
  addNode(index, newNode);
  changed();
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Convenience method for setting the point coordinate of the end point.
 * If the BezierFigure has not at least two nodes, nodes are added
 * to the figure until the BezierFigure has at least two nodes.
 */
public void setEndPoint(Point2D.Double p) {
  // Add two nodes if we haven't at least two nodes
  for (int i = getNodeCount(); i < 2; i++) {
    addNode(0, new BezierPath.Node(p.x, p.y));
  }
  setPoint(getNodeCount() - 1, p);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

  @Override
  public void undo() throws CannotUndoException {
    super.undo();
    view.removeFromSelection(f);
    f.willChange();
    f.addNode(index, removedNode);
    f.changed();
    view.addToSelection(f);
  }
});
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

  @Override
  public void undo() throws CannotUndoException {
    super.undo();
    view.removeFromSelection(f);
    f.willChange();
    f.addNode(index, removedNode);
    f.changed();
    view.addToSelection(f);
  }
});
origin: net.imagej/imagej-ui-swing

@Override
public void updateFigure(final OverlayView view, final BezierFigure figure) {
  super.updateFigure(view, figure);
  assert view.getData() instanceof GeneralPathOverlay;
  final GeneralPathOverlay gpo = (GeneralPathOverlay) view.getData();
  final GeneralPathRegionOfInterest gpr = gpo.getRegionOfInterest();
  final PathIterator pi = gpr.getGeneralPath().getPathIterator(null);
  final int nCount = figure.getNodeCount();
  int i = 0;
  final double[] pos = new double[6];
  while (!pi.isDone()) {
    pi.currentSegment(pos);
    final Node n = new Node(pos[0], pos[1]);
    if (i < nCount) figure.getNode(i).setTo(n);
    else figure.addNode(n);
    pi.next();
    i++;
  }
  while (i < figure.getNodeCount())
    figure.removeNode(i);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

protected void addPointToFigure(Point2D.Double newPoint) {
  int pointCount = createdFigure.getNodeCount();
  createdFigure.willChange();
  if (pointCount < 2) {
    createdFigure.addNode(new BezierPath.Node(newPoint));
  } else {
    Point2D.Double endPoint = createdFigure.getEndPoint();
    Point2D.Double secondLastPoint = (pointCount <= 1) ? endPoint : createdFigure.getPoint(pointCount - 2, 0);
    if (newPoint.equals(endPoint)) {
      // nothing to do
    } else if (pointCount > 1 && Geom.lineContainsPoint(newPoint.x, newPoint.y, secondLastPoint.x, secondLastPoint.y, endPoint.x, endPoint.y, 0.9f / getView().getScaleFactor())) {
      createdFigure.setPoint(pointCount - 1, 0, newPoint);
    } else {
      createdFigure.addNode(new BezierPath.Node(newPoint));
    }
  }
  createdFigure.changed();
}
origin: net.imagej/imagej-ui-swing

@Override
public void updateFigure(final OverlayView view, final BezierFigure figure) {
  super.updateFigure(view, figure);
  final PolygonOverlay polygonOverlay = downcastOverlay(view.getData());
  final PolygonRegionOfInterest roi = polygonOverlay.getRegionOfInterest();
  final int vertexCount = roi.getVertexCount();
  while (figure.getNodeCount() > vertexCount) {
    figure.removeNode(vertexCount);
  }
  for (int i = 0; i < vertexCount; i++) {
    final RealLocalizable vertex = roi.getVertex(i);
    final double x = vertex.getDoublePosition(0);
    final double y = vertex.getDoublePosition(1);
    if (figure.getNodeCount() == i) {
      figure.addNode(new Node(x, y));
    }
    else {
      final Node node = figure.getNode(i);
      node.mask = 0;
      Arrays.fill(node.x, x);
      Arrays.fill(node.y, y);
    }
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

createdFigure.addNode(new BezierPath.Node(
    creationView.getConstrainer().constrainPoint(
    creationView.viewToDrawing(anchor))));
org.jhotdraw.drawBezierFigureaddNode

Javadoc

Adds a node to the list of points.

Popular methods of BezierFigure

  • <init>
    Creates an empty BezierFigure, for example without anyBezierPath.Nodes. The BezierFigure will not dr
  • clone
  • getBezierPath
    Returns a clone of the bezier path of this figure.
  • set
  • setBezierPath
  • addFigureListener
  • createHandles
  • getBounds
  • getNode
    Gets a control point.
  • getNodeCount
    Gets the node count.
  • removeNode
    Removes the Node at the specified index.
  • restoreAttributesTo
  • removeNode,
  • restoreAttributesTo,
  • setAttributeEnabled,
  • setAttributes,
  • changed,
  • chop,
  • drawCaps,
  • findSegment,
  • fireUndoableEditHappened

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • Menu (java.awt)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Top PhpStorm plugins
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