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

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

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

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/**
 * Convenience method for getting the end point.
 */
@Override
public Point2D.Double getEndPoint() {
  return getPoint(getNodeCount() - 1, 0);
}
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

  @Override
  protected int getBezierNodeIndex() {
    return getBezierFigure().getNodeCount() - 1;
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public Point2D.Double locate(Figure owner) {
  BezierFigure plf = (BezierFigure) owner;
  if (index < plf.getNodeCount()) {
    return plf.getPoint(index, coord);
  }
  return new Point2D.Double(0, 0);
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public boolean isCombinableWith(Handle h) {
  if (super.isCombinableWith(h)) {
    BezierControlPointHandle that = (BezierControlPointHandle) h;
    return that.index == this.index &&
        that.controlPointIndex == this.controlPointIndex &&
        that.getBezierFigure().getNodeCount() ==
        this.getBezierFigure().getNodeCount();
  }
  return false;
}
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 draw(Graphics2D g) {
  if (createdFigure != null && //
      anchor != null && //
      mouseLocation != null &&//
      getView() == creationView) {
    g.setColor(Color.BLACK);
    g.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0f, new float[]{1f, 5f}, 0f));
    g.drawLine(anchor.x, anchor.y, mouseLocation.x, mouseLocation.y);
    if (!isWorking && createdFigure.isClosed() && createdFigure.getNodeCount() > 1) {
      Point p = creationView.drawingToView(createdFigure.getStartPoint());
      g.drawLine(mouseLocation.x, mouseLocation.y, p.x, p.y);
    }
  }
}
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 mouseMoved(MouseEvent evt) {
  if (createdFigure != null && anchor != null && mouseLocation != null) {
    if (evt.getSource() == creationView) {
      Rectangle r = new Rectangle(anchor);
      r.add(mouseLocation);
      r.add(evt.getPoint());
      if (createdFigure.isClosed() && createdFigure.getNodeCount() > 0) {
        r.add(creationView.drawingToView(createdFigure.getStartPoint()));
      }
      r.grow(1, 1);
      fireAreaInvalidated(r);
      mouseLocation = evt.getPoint();
    }
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Nullable
protected BezierPath.Node getBezierNode() {
  return getOwner().getNodeCount() > index ? getOwner().getNode(index) : null;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Nullable
protected BezierPath.Node getBezierNode() {
  return getBezierFigure().getNodeCount() > index ? getBezierFigure().getNode(index) : null;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

protected Point getLocation() {
  if (getBezierFigure().getNodeCount() > index) {
    Point2D.Double p = getBezierFigure().getPoint(index, controlPointIndex);
    if (getTransformOwner().get(TRANSFORM) != null) {
      getTransformOwner().get(TRANSFORM).transform(p, p);
    }
    return view.drawingToView(p);
  } else {
    return new Point(10, 10);
  }
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

protected Point getLocation() {
  if (getOwner().getNodeCount() > index) {
    Point2D.Double p = getOwner().getPoint(index, 0);
    if (getTransformOwner().get(TRANSFORM) != null) {
      getTransformOwner().get(TRANSFORM).transform(p, p);
    }
    return view.drawingToView(p);
  } else {
    return new Point(10, 10);
  }
}
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

@Nullable
protected BezierPath.Node getBezierNode() {
  int index = getBezierNodeIndex();
  return getBezierFigure().getNodeCount() > index ? getBezierFigure().getNode(index) : null;
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public Rectangle2D.Double getDrawingArea() {
  Rectangle2D.Double r = super.getDrawingArea();
  if (getNodeCount() > 1) {
    if (get(START_DECORATION) != null) {
      Point2D.Double p1 = getPoint(0, 0);
      Point2D.Double p2 = getPoint(1, 0);
      r.add(get(START_DECORATION).getDrawingArea(this, p1, p2));
    }
    if (get(END_DECORATION) != null) {
      Point2D.Double p1 = getPoint(getNodeCount() - 1, 0);
      Point2D.Double p2 = getPoint(getNodeCount() - 2, 0);
      r.add(get(END_DECORATION).getDrawingArea(this, p1, p2));
    }
  }
  return r;
}
origin: net.imagej/imagej-ui-swing

@Override
public void updateOverlay(final BezierFigure figure, final OverlayView view) {
  super.updateOverlay(figure, view);
  assert view.getData() instanceof GeneralPathOverlay;
  final GeneralPathOverlay gpo = (GeneralPathOverlay) view.getData();
  final GeneralPathRegionOfInterest gpr = gpo.getRegionOfInterest();
  gpr.reset();
  for (int i = 0; i < figure.getNodeCount(); i++) {
    final Node n = figure.getNode(i);
    if (i == 0) gpr.moveTo(n.x[0], n.y[0]);
    else gpr.lineTo(n.x[0], n.y[0]);
  }
  gpo.update();
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void deactivate(DrawingEditor editor) {
  super.deactivate(editor);
  getView().setCursor(Cursor.getDefaultCursor());
  if (createdFigure != null) {
    if (anchor != null && mouseLocation != null) {
      Rectangle r = new Rectangle(anchor);
      r.add(mouseLocation);
      if (createdFigure.getNodeCount() > 0 && createdFigure.isClosed()) {
        r.add(getView().drawingToView(createdFigure.getStartPoint()));
      }
      fireAreaInvalidated(r);
    }
    finishCreation(createdFigure, creationView);
    createdFigure = null;
  }
}
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: org.opentcs.thirdparty.jhotdraw/jhotdraw

protected void writePoints(DOMOutput out) throws IOException {
  out.openElement("points");
  if (isClosed()) {
    out.addAttribute("closed", true);
  }
  for (int i = 0, n = getNodeCount(); i < n; i++) {
    BezierPath.Node node = getNode(i);
    out.openElement("p");
    out.addAttribute("mask", node.mask, 0);
    out.addAttribute("colinear", true);
    out.addAttribute("x", node.x[0]);
    out.addAttribute("y", node.y[0]);
    out.addAttribute("c1x", node.x[1], node.x[0]);
    out.addAttribute("c1y", node.y[1], node.y[0]);
    out.addAttribute("c2x", node.x[2], node.x[0]);
    out.addAttribute("c2y", node.y[2], node.y[0]);
    out.closeElement();
  }
  out.closeElement();
}
org.jhotdraw.drawBezierFiguregetNodeCount

Javadoc

Gets the node count.

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
  • addNode
    Adds a control point.
  • createHandles
  • getBounds
  • getNode
    Gets a control point.
  • removeNode
    Removes the Node at the specified index.
  • restoreAttributesTo
  • removeNode,
  • restoreAttributesTo,
  • setAttributeEnabled,
  • setAttributes,
  • changed,
  • chop,
  • drawCaps,
  • findSegment,
  • fireUndoableEditHappened

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Best IntelliJ 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