コード例 #1
0
ファイル: SideViewJPanel.java プロジェクト: usnistgov/crcl
 private boolean paintSimpleRobot(Dimension d, Graphics2D g2d) {
   if (null == jointvals || jointvals.length < SimulatedKinematicsSimple.NUM_JOINTS) {
     return true;
   }
   maxSimpleJv0 = Math.max(maxSimpleJv0, jointvals[0]);
   double sfactor =
       Math.min(d.width / 2.0, d.height / 2.0)
           / (Math.abs(maxSimpleJv0) + SimulatedKinematicsSimple.DEFAULT_SEGLENGTHS[0]);
   g2d.scale(sfactor, -1.0 * sfactor);
   g2d.setColor(Color.gray);
   g2d.fill(j1circle);
   l0rect.width = jointvals[0];
   g2d.rotate(Math.toRadians(jointvals[2]));
   g2d.setColor(Color.yellow);
   g2d.fill(l0rect);
   g2d.translate(l0rect.width, 0.0);
   g2d.setColor(Color.gray);
   g2d.fill(j1circle);
   l1rect.width =
       Math.cos(Math.toRadians(jointvals[5] - jointvals[2]))
           * SimulatedKinematicsSimple.DEFAULT_SEGLENGTHS[0];
   g2d.rotate(Math.toRadians(jointvals[4] - jointvals[2]));
   g2d.setColor(Color.yellow);
   g2d.fill(l1rect);
   return false;
 }
コード例 #2
0
  public Rectangle2D.Double calculateLayout(
      CompositeFigure compositeFigure, Point2D.Double anchor, Point2D.Double lead) {
    Rectangle2D.Double bounds = null;

    for (Figure child : compositeFigure.getChildren()) {
      Locator locator = getLocator(child);
      Rectangle2D.Double r;
      if (locator == null) {
        r = child.getBounds();
      } else {
        Point2D.Double p = locator.locate(compositeFigure);
        Dimension2DDouble d = child.getPreferredSize();
        r = new Rectangle2D.Double(p.x, p.y, d.width, d.height);
      }
      if (!r.isEmpty()) {
        if (bounds == null) {
          bounds = r;
        } else {
          bounds.add(r);
        }
      }
    }

    return (bounds == null) ? new Rectangle2D.Double() : bounds;
  }
コード例 #3
0
  public AngleLocalization(
      List<PolygonObstacle> cSpaceObstacles,
      Rectangle2D.Double cSpaceWorld,
      Point2D.Double robotStart,
      Fiducial[] fiducialPairs) {

    this.cSpaceObstacles = cSpaceObstacles;
    this.cSpaceWorld = cSpaceWorld;
    this.robotStart = robotStart;
    this.fiducialPairs = fiducialPairs;

    particles = new ArrayList<OdoPoint>();
    probabilities = new ArrayList<Double>();

    double delta_x = 0;
    double delta_y = 0;
    double delta_theta = 0;
    for (int i = 0; i < NUM_PARTICLES; i++) {
      delta_x = cSpaceWorld.getWidth() * INITIAL_NOISE * (1 - 2 * Math.random());
      delta_y = cSpaceWorld.getHeight() * INITIAL_NOISE * (1 - 2 * Math.random());
      delta_theta = 2 * Math.PI * INITIAL_NOISE * (1 - 2 * Math.random());
      particles.add(new OdoPoint(robotStart.x + delta_x, robotStart.y + delta_y, delta_theta));
      probabilities.add(1.0 / NUM_PARTICLES);
    }

    prev_odo_x = robotStart.x;
    prev_odo_y = robotStart.y;
    prev_odo_theta = 0;
    localPoint = new OdoPoint(robotStart.x, robotStart.y, 0);
  }
コード例 #4
0
  /**
   * Reimplementación del método mouseReleased de Behavior.
   *
   * @param e MouseEvent
   * @throws BehaviorException Excepción lanzada cuando el Behavior.
   */
  public void mouseReleased(MouseEvent e) throws BehaviorException {
    super.mouseReleased(e);
    dragged = false;
    if (getLayoutControl().getFirstPoint() == null) return;
    Point2D p1;
    Point2D p2;
    Point pScreen = getLayoutControl().getLastPoint();

    AffineTransform at = getLayoutControl().getAT();

    p1 = FLayoutUtilities.toSheetPoint(getLayoutControl().getFirstPoint(), at);
    p2 = FLayoutUtilities.toSheetPoint(pScreen, at);

    if (e.getButton() == MouseEvent.BUTTON1) {
      //	Fijamos el nuevo extent
      Rectangle2D.Double r = new Rectangle2D.Double();
      r.setFrameFromDiagonal(p1, p2);

      Rectangle2D rectPixel = new Rectangle();
      rectPixel.setFrameFromDiagonal(getLayoutControl().getFirstPoint(), pScreen);

      RectangleEvent event = new RectangleEvent(r, e, rectPixel);
      listener.rectangle(event);
    }
  }
コード例 #5
0
ファイル: JImageObject.java プロジェクト: hashrock/JDrafter
 @Override
 public int hitByPoint(JEnvironment env, JRequest req, Point2D point) {
   if (isLocked() || !isVisible()) return JRequest.HIT_NON;
   Shape s = getShape();
   if (s.contains(point)) {
     req.hitObjects.add(this);
     return (req.hitResult = JRequest.HIT_OBJECT);
   }
   double radius = JEnvironment.PATH_SELECTOR_SIZE / 2 / env.getToScreenRatio();
   Rectangle2D.Double sr = new Rectangle2D.Double(0, 0, radius * 2, radius * 2);
   PathIterator path = s.getPathIterator(null);
   double[] coords = new double[6];
   while (!path.isDone()) {
     int type = path.currentSegment(coords);
     if (type == path.SEG_LINETO || type == path.SEG_MOVETO) {
       sr.x = coords[0] - radius;
       sr.y = coords[1] - radius;
       if (sr.contains(point)) {
         req.hitObjects.add(this);
         return (req.hitResult = JRequest.HIT_OBJECT);
       }
     }
     path.next();
   }
   return JRequest.HIT_NON;
 }
コード例 #6
0
  public void addFixture(Shape shape, int offsetX, int offsetY) {
    BodyFixture collFix;

    switch (shape.getClass().getCanonicalName()) {
      case "java.awt.geom.Rectangle2D.Double":
        // create and add fixture
        Rectangle2D.Double newRect = (Rectangle2D.Double) shape;
        Rectangle collisionRect = new Rectangle(newRect.width, newRect.height);
        collFix = new BodyFixture(collisionRect);
        collisionRect.translate(offsetX, offsetY);
        collFix.setDensity(1);
        this.addFixture(collFix);

        // offset shape and add to drawing ahape list
        newRect.x += offsetX;
        newRect.y += offsetY;
        shapeList.add(newRect);
        break;
      case "java.awt.geom.Ellipse2D.Double":
        Ellipse2D.Double newEllipse = (Ellipse2D.Double) shape;
        Ellipse collisionEllipse = new Ellipse(newEllipse.width, newEllipse.height);
        collFix = new BodyFixture(collisionEllipse);
        collisionEllipse.translate(offsetX, offsetY);
        collFix.setDensity(1);
        this.addFixture(collFix);

        // offset shape and add to drawing ahape list
        newEllipse.x += offsetX;
        newEllipse.y += offsetY;
        shapeList.add(newEllipse);
        break;
    }
  }
コード例 #7
0
ファイル: SVGTextFigure.java プロジェクト: DevBoost/Reuseware
 public Rectangle2D.Double getBounds() {
   if (cachedBounds == null) {
     cachedBounds = new Rectangle2D.Double();
     cachedBounds.setRect(getTextShape().getBounds2D());
   }
   return (Rectangle2D.Double) cachedBounds.clone();
 }
コード例 #8
0
ファイル: XHybridIndex.java プロジェクト: danhan/Huploader
  /**
   * @deprecated match the input rectangle to support range query the return is
   * @param x
   * @param y
   * @param radius
   * @return an array of two boxes object, and the first box represents the left top point and the
   *     second box represents the right bottom point
   */
  public Hashtable<String, XBox[]> dmatch(double x, double y, double radius) {
    System.out.println("in matching./..." + x + ";" + y);
    Rectangle2D.Double matchRect =
        new Rectangle2D.Double(x - radius, y - radius, 2 * radius, 2 * radius);
    List<XQuadTree> tiles = this.quadtree.tileMatch(x, y, radius);
    Hashtable<String, XBox[]> result = null;
    try {
      if (tiles != null && tiles.size() > 0) {
        result = new Hashtable<String, XBox[]>();
        for (int i = 0; i < tiles.size(); i++) {
          XQuadTree oneTile = tiles.get(i);
          String tileIndex = oneTile.getIndex();
          // get the tile rect where the point is located
          Rectangle2D.Double tile_rect = oneTile.getM_rect();
          Point2D.Double offsetPoint = new Point2D.Double(tile_rect.getX(), tile_rect.getY());
          X2DGrid grid = new X2DGrid(tile_rect, this.cell_size, offsetPoint);
          XBox[] range = grid.intersect(matchRect);
          result.put(tileIndex, range);
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return result;
  }
コード例 #9
0
ファイル: VProfileJoin.java プロジェクト: akoyro/furman
 @Override
 public Rectangle2D.Double getDrawingArea() {
   Rectangle2D.Double r =
       new Rectangle2D.Double(
           rec.getMinX() - 10, rec.getMinY() - 10, rec.getMaxX() + 10, rec.getMaxY() + 10);
   return r;
 }
コード例 #10
0
ファイル: CSpace.java プロジェクト: nforrester/6.141_labs
 // robot reference point is the origin
 public CSpace(Polygon robot, PolygonMap map) {
   Rectangle2D.Double worldRect = map.getWorldRect();
   constructor(
       robot, worldRect.getMinX(), worldRect.getMinY(), worldRect.getMaxX(), worldRect.getMaxY());
   for (PolygonObstacle obstacle : map.getObstacles()) {
     addObstacle(obstacle);
   }
 }
コード例 #11
0
ファイル: GranM.java プロジェクト: pratTeam/granm
  public static void loadingText(String string) {
    if (loadingScreen != null) {
      loadingGraphics.setPaint(Color.WHITE);
      loadingGraphics.drawString(
          string, (int) loadingTextArea.getX(), (int) loadingTextArea.getY() + 20);

      loadingScreen.update();
    }
  }
コード例 #12
0
ファイル: RectangleAdapter.java プロジェクト: CaTaHaTa/imagej
 @Override
 public void updateOverlay(final Figure figure, final OverlayView overlay) {
   super.updateOverlay(figure, overlay);
   final RectangleOverlay rOverlay = downcastOverlay(overlay.getData());
   final RectangleRegionOfInterest roi = rOverlay.getRegionOfInterest();
   final Rectangle2D.Double bounds = figure.getBounds();
   roi.setOrigin(bounds.getMinX(), 0);
   roi.setOrigin(bounds.getMinY(), 1);
   roi.setExtent(bounds.getWidth(), 0);
   roi.setExtent(bounds.getHeight(), 1);
 }
コード例 #13
0
  /**
   * Renders the shape that is currently being sized by the user as they drag the mouse across the
   * canvas. We render this separately because we have not yet put it in the shapes list for the
   * pose.
   *
   * @param g2 The graphics context for this canvas.
   * @param poseArea The area in the middle of the canvas where the pose will be rendered.
   */
  private void renderShapeInProgress(Graphics2D g2, Rectangle2D.Double poseArea) {
    AnimatedSpriteEditor singleton = AnimatedSpriteEditor.getEditor();
    PoseurStateManager poseurStateManager = singleton.getStateManager().getPoseurStateManager();
    PoseurShape shapeInProgress = poseurStateManager.getShapeInProgress();

    // ONLY DO THIS ON THE RIGHT SIDE
    if (state.isZoomable() && (shapeInProgress != null)) {
      float zoomLevel = state.getZoomLevel();
      shapeInProgress.render(g2, (int) poseArea.getX(), (int) poseArea.getY(), zoomLevel, true);
    }
  }
コード例 #14
0
ファイル: RCMath.java プロジェクト: eddy-geek/roboteamlg
 /**
  * Returns the distance from a point within a box to the edge of a box given the point and a
  * heading in robocode degrees.
  *
  * @param x x-coordinate of point inside box
  * @param y y-coordinate of point inside box
  * @param headingRoboDegrees heading from point in robocode degrees
  * @param box box containing point
  * @return distance between point and edge of box given heading
  */
 public static double getDistanceToIntersect(
     double x, double y, double headingRoboDegrees, Rectangle2D.Double box) {
   VelocityVector vv = new VelocityVector(headingRoboDegrees, 1);
   double endX = (vv.getX() > 0) ? box.getMaxX() : box.getMinX();
   double endY = (vv.getY() > 0) ? box.getMaxY() : box.getMinY();
   double timeToX = (endX - x) / vv.getX();
   double timeToY = (endY - y) / vv.getY();
   double timeToIntercept = Math.min(timeToX, timeToY);
   double x_i = x + timeToIntercept * vv.getX();
   double y_i = y + timeToIntercept * vv.getY();
   return getDistanceBetweenPoints(x, y, x_i, y_i);
 }
コード例 #15
0
 private void writeTextAreaElement(IXMLElement parent, SVGTextAreaFigure f) throws IOException {
     IXMLElement elem = parent.createElement("AREA");
     Rectangle2D.Double rect = f.getBounds();
     double grow = getPerpendicularHitGrowth(f);
     rect.x -= grow;
     rect.y -= grow;
     rect.width += grow;
     rect.height += grow;
     if (writeRectAttributes(elem, f, rect)) {
         parent.addChild(elem);
     }
 }
コード例 #16
0
ファイル: XHybridIndex.java プロジェクト: danhan/Huploader
 public void getTiles(XQuadTree treeNode) {
   if (!treeNode.isHasChild()) { // this is the leaf node     	
     Rectangle2D.Double tile_rect = treeNode.getM_rect();
     Point2D.Double offsetPoint = new Point2D.Double(tile_rect.getX(), tile_rect.getY());
     X2DGrid grid = new X2DGrid(tile_rect, this.cell_size, offsetPoint);
     this.m_tiles.put(treeNode.getIndex(), grid);
   } else {
     this.getTiles(treeNode.getM_tl_child());
     this.getTiles(treeNode.getM_tr_child());
     this.getTiles(treeNode.getM_bl_child());
     this.getTiles(treeNode.getM_br_child());
   }
 }
コード例 #17
0
  public Rectangle2D.Double layout(
      CompositeFigure compositeFigure, Point2D.Double anchor, Point2D.Double lead) {
    Rectangle2D.Double bounds = null;

    for (Figure child : compositeFigure.getChildren()) {
      Locator locator = getLocator(child);

      Rectangle2D.Double r;
      if (locator == null) {
        r = child.getBounds();
      } else {
        Point2D.Double p = locator.locate(compositeFigure, child);
        Dimension2DDouble d = child.getPreferredSize();
        r = new Rectangle2D.Double(p.x, p.y, d.width, d.height);
      }
      child.willChange();
      child.setBounds(
          new Point2D.Double(r.getMinX(), r.getMinY()),
          new Point2D.Double(r.getMaxX(), r.getMaxY()));
      child.changed();
      if (!r.isEmpty()) {
        if (bounds == null) {
          bounds = r;
        } else {
          bounds.add(r);
        }
      }
    }

    return (bounds == null) ? new Rectangle2D.Double() : bounds;
  }
コード例 #18
0
ファイル: SurfaceImpl.java プロジェクト: automenta/mojaic
  /**
   * Do any initial initialization here. This should be called by the {@link MosaicEngine} when or
   * before executing the first layout.
   */
  void init() {
    // Initialize the smallest node size/boundaryDividerCondition
    for (Node<T> n : getNodeList()) {
      double w = n.percentWidth * area.width;
      if (w < area.width) {
        area.width = w;
      }

      double h = n.percentHeight * area.height;
      if (h < area.height) {
        area.height = h;
      }
    }
  }
コード例 #19
0
ファイル: AlgoLocus.java プロジェクト: tomasp8/geogebra
  private boolean distanceOK(GeoPoint2 Q) {
    boolean distanceOK;

    if (lastFarAway && isFarAway(Q.inhomX, Q.inhomY)) {
      // if last point Q' was far away and Q is far away
      // then the distance is probably OK (return true),
      // so we probably don't need smaller step,
      // except if the rectangle of the segment Q'Q
      // intersects the near to screen rectangle
      // (it will probably not be on the screen anyway)
      double minX = lastX;
      double minY = lastY;
      double lengthX = Q.inhomX - lastX;
      double lengthY = Q.inhomY - lastY;
      if (Q.inhomX < minX) minX = Q.inhomX;
      if (Q.inhomY < minY) minY = Q.inhomY;
      if (lengthX < 0) lengthX = -lengthX;
      if (lengthY < 0) lengthY = -lengthY;
      distanceOK = !nearToScreenRect.intersects(minX, minY, lengthX, lengthY);
    } else {
      distanceOK = distanceSmall(Q);
    }

    return distanceOK;
  }
コード例 #20
0
ファイル: XHybridIndex.java プロジェクト: danhan/Huploader
 /**
  * @deprecated get index for the data point, the column index should be appended the location id
  *     later row index: (QT tile index - row index, column index)
  * @param x latitude of the location point
  * @param y longitude of the location point
  * @return
  */
 public String[] dlocate(double x, double y) {
   // filter the tile with quad tree first
   XQuadTree tile = this.quadtree.locate(x, y);
   // get index in the first level
   String tile_index = tile.getIndex();
   // get the tile rect where the point is located
   Rectangle2D.Double tile_rect = tile.getM_rect();
   Point2D.Double offsetPoint = new Point2D.Double(tile_rect.getX(), tile_rect.getY());
   X2DGrid grid = new X2DGrid(tile_rect, this.cell_size, offsetPoint);
   XBox box = grid.locate(x, y);
   String[] indexes = new String[2];
   indexes[0] = tile_index + "-" + box.getRow();
   indexes[1] = box.getColumn();
   // System.out.println("row=> "+indexes[0]+";column=>"+indexes[1]);
   return indexes;
 }
コード例 #21
0
ファイル: MoveShapeTool.java プロジェクト: imagej/envisaje
 public void paint(Graphics2D g, Rectangle layerBounds, boolean commit) {
   if (shape == null || stack == null) {
     return;
   }
   int full = 6;
   int half = 3;
   Rectangle2D.Double scratch = new Rectangle2D.Double(0, 0, full, full);
   g.setStroke(new BasicStroke(1F));
   int max = ((Adjustable) shape).getControlPointCount();
   double[] d = new double[max * 2];
   ((Adjustable) shape).getControlPoints(d);
   Point p = layer.getSurface().getLocation();
   for (int i = 0; i < d.length; i += 2) {
     d[i] -= p.x;
     d[i + 1] -= p.y;
     scratch.x = d[i] - half;
     scratch.y = d[i + 1] - half;
     g.setColor(Color.WHITE);
     g.fill(scratch);
     g.setColor(Color.BLACK);
     g.draw(scratch);
     if (cpoint != null && cpoint.getX() == d[i] && cpoint.getY() == d[i + 1]) {
       scratch.x -= 3;
       scratch.y -= 3;
       scratch.width += 6;
       scratch.height += 6;
       g.setColor(Color.YELLOW);
       g.draw(scratch);
     }
   }
 }
コード例 #22
0
ファイル: SideViewJPanel.java プロジェクト: usnistgov/crcl
 private boolean paintPlausibleRobot(Dimension d, Graphics2D g2d) {
   double sfactor =
       Math.min(d.width / 2.0, d.height / 2.0)
           / (seglengths[0] + seglengths[1] + seglengths[2] + seglengths[3]);
   g2d.scale(sfactor, -1.0 * sfactor);
   g2d.setColor(Color.gray);
   g2d.fill(j1circle);
   if (null == jointvals) {
     return true;
   }
   g2d.rotate(Math.toRadians(jointvals[1]));
   g2d.setColor(Color.yellow);
   g2d.fill(l0rect);
   g2d.translate(l0rect.width, 0.0);
   g2d.setColor(Color.gray);
   g2d.fill(j1circle);
   g2d.rotate(Math.toRadians(jointvals[2]));
   g2d.setColor(Color.yellow);
   g2d.fill(l1rect);
   g2d.translate(l1rect.width, 0.0);
   g2d.setColor(Color.gray);
   g2d.fill(j1circle);
   g2d.rotate(Math.toRadians(jointvals[3]));
   g2d.setColor(Color.yellow);
   g2d.fill(l2rect);
   g2d.translate(l2rect.width, 0.0);
   l3rect.width = this.seglengths[3] * Math.cos(Math.toRadians(jointvals[4]));
   if (l3rect.width <= 0) {
     return true;
   }
   g2d.setColor(Color.yellow);
   g2d.fill(l3rect);
   g2d.setColor(Color.gray);
   g2d.fill(j2circle);
   g2d.translate(l3rect.width, 0.0);
   g2d.setColor(Color.BLACK);
   l4rect.height = seglengths[4] * Math.abs(Math.cos(Math.toRadians(jointvals[5])));
   l4rect.y = -0.5 * l4rect.height;
   g2d.fill(l4rect);
   g2d.translate(0.0, l4rect.height / 2.0);
   g2d.fill(l5rect);
   g2d.translate(0.0, -l4rect.height);
   g2d.fill(l5rect);
   return false;
 }
コード例 #23
0
ファイル: JImageObject.java プロジェクト: hashrock/JDrafter
 @Override
 public void paintPreview(JEnvironment env, JRequest req, Graphics2D g) {
   g.setColor(getPreviewColor());
   AffineTransform af = new AffineTransform(totalTransform);
   if (addingTransform != null) af.preConcatenate(addingTransform);
   Shape s = getShape();
   if (addingTransform != null) s = addingTransform.createTransformedShape(s);
   s = env.getToScreenTransform().createTransformedShape(s);
   g.draw(s);
   PathIterator path = s.getPathIterator(null);
   double radius = JEnvironment.PATH_SELECTOR_SIZE / 2;
   Rectangle2D.Double sr = new Rectangle2D.Double(0, 0, radius * 2, radius * 2);
   double[] coords = new double[6];
   while (!path.isDone()) {
     int type = path.currentSegment(coords);
     if (type == path.SEG_MOVETO || type == path.SEG_LINETO) {
       sr.x = coords[0] - radius;
       sr.y = coords[1] - radius;
       g.fill(sr);
     } else if (type == path.SEG_CUBICTO) {
       sr.x = coords[4] - radius;
       sr.y = coords[5] - radius;
       g.fill(sr);
     } else if (type == path.SEG_QUADTO) {
       sr.x = coords[2] - radius;
       sr.y = coords[3] - radius;
       g.fill(sr);
     }
     path.next();
   }
 }
コード例 #24
0
  /**
   * Given a co-ord checks to see if a line from it passes through its influence circle to the
   * subsequent flanks associated with it. If it does then it is a rear unit.
   */
  public void passesThrough(RCSInfluenceMapPosition enemy, String type_REAR) {
    this.enemy = enemy;
    this.enemyPos = enemy.getCenter();

    RCSInfluenceMapPosition pos1;
    Rectangle2D.Double rect =
        new Rectangle2D.Double(
            center[0] - (totalValue / 2), center[1] - (totalValue / 2), totalValue, totalValue);

    // i =1 because the first element (0) is the front itself.
    for (int i = 1; i < owns.size(); i++) {
      pos1 = (RCSInfluenceMapPosition) owns.elementAt(i);

      if (rect.intersectsLine(enemyPos[0], enemyPos[1], pos1.getCenter()[0], pos1.getCenter()[1])) {
        pos1.setType(type_REAR);
      }
    }
  }
コード例 #25
0
ファイル: BezierFigure.java プロジェクト: ilyessou/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;
  }
コード例 #26
0
ファイル: Geoset.java プロジェクト: Retera/JWC3
 public ArrayList<Vertex> getVertecesInArea(Rectangle2D.Double area, byte dim1, byte dim2) {
   ArrayList<Vertex> temp = new ArrayList<Vertex>();
   for (Vertex ver : vertex) {
     //             Point2D.Double p = new Point(ver.getCoords(dim1),ver.getCoords(dim2))
     if (area.contains(ver.getCoord(dim1), ver.getCoord(dim2))) {
       temp.add(ver);
     }
   }
   return temp;
 }
コード例 #27
0
ファイル: SVGTextFigure.java プロジェクト: DevBoost/Reuseware
 @Override
 public Rectangle2D.Double getDrawingArea() {
   if (cachedDrawingArea == null) {
     Rectangle2D rx = getBounds();
     Rectangle2D.Double r =
         (rx instanceof Rectangle2D.Double)
             ? (Rectangle2D.Double) rx
             : new Rectangle2D.Double(rx.getX(), rx.getY(), rx.getWidth(), rx.getHeight());
     double g = SVGAttributeKeys.getPerpendicularHitGrowth(this);
     Geom.grow(r, g, g);
     if (TRANSFORM.get(this) == null) {
       cachedDrawingArea = r;
     } else {
       cachedDrawingArea = new Rectangle2D.Double();
       cachedDrawingArea.setRect(TRANSFORM.get(this).createTransformedShape(r).getBounds2D());
     }
   }
   return (Rectangle2D.Double) cachedDrawingArea.clone();
 }
コード例 #28
0
ファイル: MoveShapeTool.java プロジェクト: imagej/envisaje
 public void mousePressed(MouseEvent e) {
   if (e.isPopupTrigger()) {
     showPopup(e);
     return;
   }
   if (stack == null && layer != null) stack = layer.getLookup().lookup(ShapeStack.class);
   List<Primitive> l = stack.getPrimitives();
   Rectangle2D.Double scratch = new Rectangle2D.Double(0, 0, 0, 0);
   Point point = mousePressPoint = e.getPoint();
   if (shape != null) {
     ControlPoint[] p = new ControlPointFactory().getControlPoints((Adjustable) shape, this);
     for (int i = 0; i < p.length; i++) {
       ControlPoint pt = p[i];
       if (pt.hit(point.x, point.y)) {
         setSelectedControlPoint(pt);
         return;
       }
     }
   }
   boolean found = false;
   for (Primitive p : l) {
     if (p instanceof Vector) {
       Vector vector = (Vector) p;
       Shape shape = vector.toShape();
       if (shape.contains(point.x, point.y)) {
         setSelectedShape(p);
         found = true;
       }
     } else if (p instanceof Volume) {
       Volume volume = (Volume) p;
       volume.getBounds(scratch);
       System.err.println(p);
       if (scratch.contains(point.x, point.y)) {
         setSelectedShape(p);
         found = true;
       }
     }
   }
   if (!found) {
     setSelectedShape(null);
   }
 }
コード例 #29
0
  @Override
  public void draw(Graphics2D g) {
    double opacity = get(OPACITY);
    opacity = Math.min(Math.max(0d, opacity), 1d);
    if (opacity != 0d) {
      if (opacity != 1d) {
        Rectangle2D.Double drawingArea = getDrawingArea();

        Rectangle2D clipBounds = g.getClipBounds();
        if (clipBounds != null) {
          Rectangle2D.intersect(drawingArea, clipBounds, drawingArea);
        }

        if (!drawingArea.isEmpty()) {

          BufferedImage buf =
              new BufferedImage(
                  (int) ((2 + drawingArea.width) * g.getTransform().getScaleX()),
                  (int) ((2 + drawingArea.height) * g.getTransform().getScaleY()),
                  BufferedImage.TYPE_INT_ARGB);
          Graphics2D gr = buf.createGraphics();
          gr.scale(g.getTransform().getScaleX(), g.getTransform().getScaleY());
          gr.translate((int) -drawingArea.x, (int) -drawingArea.y);
          gr.setRenderingHints(g.getRenderingHints());
          drawFigure(gr);
          gr.dispose();
          Composite savedComposite = g.getComposite();
          g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) opacity));
          g.drawImage(
              buf,
              (int) drawingArea.x,
              (int) drawingArea.y,
              2 + (int) drawingArea.width,
              2 + (int) drawingArea.height,
              null);
          g.setComposite(savedComposite);
        }
      } else {
        drawFigure(g);
      }
    }
  }
コード例 #30
0
ファイル: Geoset.java プロジェクト: Retera/JWC3
 public ArrayList<TVertex> getTVertecesInArea(Rectangle2D.Double area, int layerId) {
   ArrayList<TVertex> temp = new ArrayList<TVertex>();
   for (int i = 0; i < vertex.size(); i++) {
     TVertex ver = vertex.get(i).getTVertex(layerId);
     //             Point2D.Double p = new Point(ver.getCoords(dim1),ver.getCoords(dim2))
     if (area.contains(ver.getX(), ver.getY())) {
       temp.add(ver);
     }
   }
   return temp;
 }