congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
BezierTool.getView
Code IndexAdd Tabnine to your IDE (free)

How to use
getView
method
in
org.jhotdraw.draw.tool.BezierTool

Best Java code snippets using org.jhotdraw.draw.tool.BezierTool.getView (Showing top 8 results out of 315)

origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void mouseDragged(MouseEvent evt) {
  if (finishWhenMouseReleased == null) {
    finishWhenMouseReleased = Boolean.TRUE;
  }
  int x = evt.getX();
  int y = evt.getY();
  addPointToFigure(getView().viewToDrawing(new Point(x, y)));
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void activate(DrawingEditor editor) {
  super.activate(editor);
  getView().setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
}
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

protected BezierPath calculateFittedCurve(BezierPath path) {
  return Bezier.fitBezierPath(path, 1.5d / getView().getScaleFactor());
}
origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void mouseClicked(MouseEvent evt) {
  if (createdFigure != null) {
    switch (evt.getClickCount()) {
      case 1:
        if (createdFigure.getNodeCount() > 2) {
          Rectangle r = new Rectangle(getView().drawingToView(createdFigure.getStartPoint()));
          r.grow(2, 2);
          if (r.contains(evt.getX(), evt.getY())) {
            createdFigure.setClosed(true);
            finishCreation(createdFigure, creationView);
            createdFigure = null;
            if (isToolDoneAfterCreation) {
              fireToolDone();
            }
          }
        }
        break;
      case 2:
        finishWhenMouseReleased = null;
        finishCreation(createdFigure, creationView);
        createdFigure = null;
        break;
    }
  }
}
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

if (createdFigure != null && creationView != getView()) {
  finishCreation(createdFigure, creationView);
  createdFigure = null;
  creationView = getView();
  creationView.clearSelection();
  finishWhenMouseReleased = 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();
}
org.jhotdraw.draw.toolBezierToolgetView

Popular methods of BezierTool

  • finishCreation
  • <init>
  • addPointToFigure
  • calculateFittedCurve
  • createFigure
  • fireAreaInvalidated
  • fireToolDone
  • fireUndoEvent
  • getDrawing
  • getEditor
  • maybeFireBoundsInvalidated
  • maybeFireBoundsInvalidated

Popular in Java

  • Finding current android device location
  • getContentResolver (Context)
  • compareTo (BigDecimal)
  • setContentView (Activity)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • JTextField (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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