Java 类java.awt.geom.Line2D.Double 实例源码

项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawCatchingEvent(int x, int y, int width, int height, Image image) {
  // event circles
  Ellipse2D outerCircle = new Ellipse2D.Double(x, y, width, height);
  int innerCircleX = x + 3;
  int innerCircleY = y + 3;
  int innerCircleWidth = width - 6;
  int innerCircleHeight = height - 6;
  Ellipse2D innerCircle = new Ellipse2D.Double(innerCircleX, innerCircleY, innerCircleWidth, innerCircleHeight);

  Paint originalPaint = g.getPaint();
  g.setPaint(BOUNDARY_EVENT_COLOR);
  g.fill(outerCircle);

  g.setPaint(originalPaint);
  g.draw(outerCircle);
  g.draw(innerCircle);

  g.drawImage(image, innerCircleX, innerCircleY, innerCircleWidth, innerCircleHeight, null);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawArrowHead(Line2D.Double line, boolean fill) {
  int doubleArrowWidth = 2 * ARROW_WIDTH;
  Polygon arrowHead = new Polygon();
  arrowHead.addPoint(0, 0);
  arrowHead.addPoint(-ARROW_WIDTH, -doubleArrowWidth);
  arrowHead.addPoint(ARROW_WIDTH, -doubleArrowWidth);

  AffineTransform transformation = calcAffineTransformation(line);

  AffineTransform originalTransformation = g.getTransform();
  g.setTransform(transformation);
  if (fill) {
    g.fill(arrowHead);
  } else {
    Color oldColor = g.getColor();
    g.setColor(Color.WHITE);
    g.fillPolygon(arrowHead);
    g.setColor(oldColor);
    g.draw(arrowHead);
  }
  g.setTransform(originalTransformation);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
protected void drawTask(String name, int x, int y, int width, int height, boolean thickBorder) {
  Paint originalPaint = g.getPaint();
  g.setPaint(TASK_COLOR);

  // shape
  RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width, height, 20, 20);
  g.fill(rect);
  g.setPaint(originalPaint);

  if (thickBorder) {
    Stroke originalStroke = g.getStroke();
    g.setStroke(THICK_TASK_BORDER_STROKE);
    g.draw(rect);
    g.setStroke(originalStroke);
  } else {
    g.draw(rect);
  }

  // text
  if (name != null) {
    String text = fitTextToWidth(name, width);
    int textX = x + ((width - fontMetrics.stringWidth(text)) / 2);
    int textY = y + ((height - fontMetrics.getHeight()) / 2) + fontMetrics.getHeight();
    g.drawString(text, textX, textY);
  }
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawExclusiveGateway(int x, int y, int width, int height) {
  // rhombus
  drawGateway(x, y, width, height);

  int quarterWidth = width / 4;
  int quarterHeight = height / 4;

  // X inside rhombus
  Stroke orginalStroke = g.getStroke();
  g.setStroke(GATEWAY_TYPE_STROKE);
  Line2D.Double line = new Line2D.Double(x + quarterWidth + 3, y + quarterHeight + 3, x + 3 * quarterWidth - 3, y + 3 * quarterHeight - 3);
  g.draw(line);
  line = new Line2D.Double(x + quarterWidth + 3, y + 3 * quarterHeight - 3, x + 3 * quarterWidth - 3, y + quarterHeight + 3);
  g.draw(line);

  g.setStroke(orginalStroke);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawMultiInstanceMarker(boolean sequential, int x, int y, int width, int height) {
  int rectangleWidth = MARKER_WIDTH;
  int rectangleHeight = MARKER_WIDTH;
  int lineX = x + (width - rectangleWidth) / 2;
  int lineY = y + height - rectangleHeight - 3;

  Stroke orginalStroke = g.getStroke();
  g.setStroke(MULTI_INSTANCE_STROKE);

  if (sequential) {
    g.draw(new Line2D.Double(lineX, lineY, lineX + rectangleWidth, lineY));
    g.draw(new Line2D.Double(lineX, lineY + rectangleHeight / 2, lineX + rectangleWidth, lineY + rectangleHeight / 2));
    g.draw(new Line2D.Double(lineX, lineY + rectangleHeight, lineX + rectangleWidth, lineY + rectangleHeight));
  } else {
    g.draw(new Line2D.Double(lineX, lineY, lineX, lineY + rectangleHeight));
    g.draw(new Line2D.Double(lineX + rectangleWidth / 2, lineY, lineX + rectangleWidth / 2, lineY + rectangleHeight));
    g.draw(new Line2D.Double(lineX + rectangleWidth, lineY, lineX + rectangleWidth, lineY + rectangleHeight));
  }

  g.setStroke(orginalStroke);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawStartEvent(int x, int y, int width, int height, Image image) {
  g.draw(new Ellipse2D.Double(x, y, width, height));
  if (image != null) {
    g.drawImage(image, x, y, width, height, null);
  }

}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawSequenceflow(int srcX, int srcY, int targetX, int targetY, boolean conditional) {
  Line2D.Double line = new Line2D.Double(srcX, srcY, targetX, targetY);
  g.draw(line);
  drawArrowHead(line, true);

  if (conditional) {
    drawConditionalSequenceFlowIndicator(line);
  }
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawSequenceflowWithoutArrow(int srcX, int srcY, int targetX, int targetY, boolean conditional) {
  Line2D.Double line = new Line2D.Double(srcX, srcY, targetX, targetY);
  g.draw(line);

  if (conditional) {
    drawConditionalSequenceFlowIndicator(line);
  }
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawLinedArrowHead(Double line, boolean b) {
  int doubleArrowWidth = 2 * ARROW_WIDTH;
  Path2D arrowHead = new Path2D.Float();
  arrowHead.moveTo(-ARROW_WIDTH, -doubleArrowWidth);
  arrowHead.lineTo(0, 0);
  arrowHead.lineTo(ARROW_WIDTH, -doubleArrowWidth);

  AffineTransform transformation = calcAffineTransformation(line);

  AffineTransform originalTransformation = g.getTransform();
  g.setTransform(transformation);
  g.draw(arrowHead);
  g.setTransform(originalTransformation);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
protected AffineTransform calcAffineTransformation(Double line) {
  AffineTransform transformation = new AffineTransform();
  transformation.setToIdentity();
  double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
  transformation.translate(line.x2, line.y2);
  transformation.rotate((angle - Math.PI / 2d));
  return transformation;
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawConditionalSequenceFlowIndicator(Line2D.Double line) {
  int horizontal = (int) (CONDITIONAL_INDICATOR_WIDTH * 0.7);
  int halfOfHorizontal = horizontal / 2;
  int halfOfVertical = CONDITIONAL_INDICATOR_WIDTH / 2;

  Polygon conditionalIndicator = new Polygon();
  conditionalIndicator.addPoint(0, 0);
  conditionalIndicator.addPoint(-halfOfHorizontal, halfOfVertical);
  conditionalIndicator.addPoint(0, CONDITIONAL_INDICATOR_WIDTH);
  conditionalIndicator.addPoint(halfOfHorizontal, halfOfVertical);

  AffineTransform transformation = new AffineTransform();
  transformation.setToIdentity();
  double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
  transformation.translate(line.x1, line.y1);
  transformation.rotate((angle - Math.PI / 2d));

  AffineTransform originalTransformation = g.getTransform();
  g.setTransform(transformation);
  g.draw(conditionalIndicator);

  Paint originalPaint = g.getPaint();
  g.setPaint(CONDITIONAL_INDICATOR_COLOR);
  g.fill(conditionalIndicator);

  g.setPaint(originalPaint);
  g.setTransform(originalTransformation);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawMessageFlowWithoutArrow(int srcX, int srcY, int targetX, int targetY) {
  Line2D.Double line = new Line2D.Double(srcX, srcY, targetX, targetY);
  BasicStroke currentStroke = (BasicStroke) g.getStroke();
  Stroke dashedStroke = new BasicStroke(currentStroke.getLineWidth(),
          BasicStroke.CAP_BUTT, currentStroke.getLineJoin(),
          currentStroke.getMiterLimit(), new float[] { 2.0f, 4.0f },
          currentStroke.getDashPhase());
  g.setStroke(dashedStroke);
  g.draw(line);
  g.setStroke(currentStroke);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawMessageFlowStart(int x, int y) {
  int radius = 4;
  Ellipse2D.Double circle = new Ellipse2D.Double(x - radius, y - radius, 2 * radius, 2 * radius);
  Color oldColor = g.getColor();
  g.setColor(Color.WHITE);
  g.fill(circle);
  g.setColor(oldColor);
  g.draw(circle);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawExpandedSubProcess(String name, int x, int y, int width, int height) {
  RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width, height, 20, 20);
  g.draw(rect);

  String text = fitTextToWidth(name, width);
  g.drawString(text, x + 10, y + 15);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawCollapsedMarker(int x, int y, int width, int height) {
  // rectangle
  int rectangleWidth = MARKER_WIDTH;
  int rectangleHeight = MARKER_WIDTH;
  Rectangle rect = new Rectangle(x + (width - rectangleWidth) / 2, y + height - rectangleHeight - 3, rectangleWidth, rectangleHeight);
  g.draw(rect);

  // plus inside rectangle
  Line2D.Double line = new Line2D.Double(rect.getCenterX(), rect.getY() + 2, rect.getCenterX(), rect.getMaxY() - 2);
  g.draw(line);
  line = new Line2D.Double(rect.getMinX() + 2, rect.getCenterY(), rect.getMaxX() - 2, rect.getCenterY());
  g.draw(line);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawParallelGateway(int x, int y, int width, int height) {
  // rhombus
  drawGateway(x, y, width, height);

  // plus inside rhombus
  Stroke orginalStroke = g.getStroke();
  g.setStroke(GATEWAY_TYPE_STROKE);
  Line2D.Double line = new Line2D.Double(x + 10, y + height / 2, x + width - 10, y + height / 2); // horizontal
  g.draw(line);
  line = new Line2D.Double(x + width / 2, y + height - 10, x + width / 2, y + 10); // vertical
  g.draw(line);
  g.setStroke(orginalStroke);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawInclusiveGateway(int x, int y, int width, int height) {
  // rhombus
  drawGateway(x, y, width, height);

  int diameter = width / 2;

  // circle inside rhombus
  Stroke orginalStroke = g.getStroke();
  g.setStroke(GATEWAY_TYPE_STROKE);
  Ellipse2D.Double circle = new Ellipse2D.Double(((width - diameter) / 2) + x, ((height - diameter) / 2) + y, diameter, diameter);
  g.draw(circle);
  g.setStroke(orginalStroke);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawHighLight(int x, int y, int width, int height) {
  Paint originalPaint = g.getPaint();
  Stroke originalStroke = g.getStroke();

  g.setPaint(HIGHLIGHT_COLOR);
  g.setStroke(THICK_TASK_BORDER_STROKE);

  RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width, height, 20, 20);
  g.draw(rect);

  g.setPaint(originalPaint);
  g.setStroke(originalStroke);
}
项目:Calico    文件:CStrokeController.java   
public static long getPotentialScrap(Point p)
{
    if (p == null)
        return 0l;

    long[] strokes = CCanvasController.canvasdb.get(CCanvasController.getCurrentUUID()).getChildStrokes();

    long smallestStroke = 0l;
    double strokeArea = java.lang.Double.MAX_VALUE;
    Polygon temp;
    double tempArea;
    for (int i = 0; i < strokes.length; i++)
    {
        temp = CStrokeController.strokes.get(strokes[i]).getPolygon();
        tempArea = Geometry.computePolygonArea(temp);
        if (temp.contains(p) 
                && tempArea < strokeArea
                && new Point(temp.xpoints[0],temp.ypoints[0])
                    .distance(new Point(temp.xpoints[temp.npoints-1],temp.ypoints[temp.npoints-1])) 
                    < calico.CalicoOptions.pen.press_and_hold_menu_radius * 4)
        {
            smallestStroke = strokes[i];
            strokeArea = tempArea;
        }
    }
    return smallestStroke;
}
项目:PhET    文件:Beaker.java   
private Rectangle2D.Double toRectangle() {
    return new Rectangle2D.Double( x, y, width, height + topExtension );
}
项目:PhET    文件:Beaker.java   
public Point2D getOutputFaucetAttachmentPoint() {
    return new Point2D.Double( x + width, y );
}
项目:PhET    文件:Beaker.java   
public Line2D.Double getLeftWall() {
    return new Line2D.Double( x, y, x, y + height );
}
项目:PhET    文件:Beaker.java   
public Line2D.Double getRightWall() {
    return new Line2D.Double( getMaxX(), y, getMaxX(), y + height );
}
项目:PhET    文件:Beaker.java   
public Line2D.Double getFloor() {
    return new Double( x, y, x + width, y );
}
项目:PhET    文件:Beaker.java   
public Rectangle2D.Double getWaterShape( double y, double volume ) {
    return new Rectangle2D.Double( getX(), getY() + y, getWidth(), getHeightForVolume( volume ) );
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawNoneEndEvent(int x, int y, int width, int height) {
  Stroke originalStroke = g.getStroke();
  g.setStroke(END_EVENT_STROKE);
  g.draw(new Ellipse2D.Double(x, y, width, height));
  g.setStroke(originalStroke);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawDataAssociation(int srcX, int srcY, int targetX, int targetY) {
  drawMessageFlowWithoutArrow(srcX, srcY, targetX, targetY);
  Line2D.Double line = new Line2D.Double(srcX, srcY, targetX, targetY);
  drawLinedArrowHead(line, false);
}
项目:FiWare-Template-Handler    文件:ProcessDiagramCanvas.java   
public void drawMessageFlow(int srcX, int srcY, int targetX, int targetY) {
  drawMessageFlowWithoutArrow(srcX, srcY, targetX, targetY);
  Line2D.Double line = new Line2D.Double(srcX, srcY, targetX, targetY);
  drawArrowHead(line, false);
}
项目:Calico    文件:CStrokeController.java   
public static long getPotentialConnector(Point p, int maxDistance)
{
    if (p == null)
        return 0l;

    long[] strokes = CCanvasController.canvasdb.get(CCanvasController.getCurrentUUID()).getChildStrokes();

    long closestStroke = 0l;
    double minStrokeDistance = java.lang.Double.MAX_VALUE;
    Polygon temp;
    for (int i = 0; i < strokes.length; i++)
    {
        temp = CStrokeController.strokes.get(strokes[i]).getPolygon();

        long tailUUID = CGroupController.get_smallest_containing_group_for_point(CCanvasController.getCurrentUUID(), new Point(temp.xpoints[0], temp.ypoints[0]));
        long headUUID = CGroupController.get_smallest_containing_group_for_point(CCanvasController.getCurrentUUID(), new Point(temp.xpoints[temp.npoints - 1], temp.ypoints[temp.npoints - 1]));

        if (tailUUID != 0l && headUUID != 0l 
                && !(tailUUID == headUUID && CGroupController.groupdb.get(headUUID).containsShape(temp))
                && !(CGroupController.groupdb.get(tailUUID) instanceof CListDecorator) && !(CGroupController.groupdb.get(headUUID) instanceof CListDecorator))
        {
            double minSegmentDistance = java.lang.Double.MAX_VALUE;
            for (int j = 0; j < temp.npoints - 1; j++)
            {
                double[] intersectPoint = Geometry.computeIntersectingPoint(temp.xpoints[j], temp.ypoints[j], temp.xpoints[j+1], temp.ypoints[j+1], p.x, p.y);
                double AtoB = Geometry.length(temp.xpoints[j], temp.ypoints[j], temp.xpoints[j+1], temp.ypoints[j+1]);
                double AtoI = Geometry.length(temp.xpoints[j], temp.ypoints[j], intersectPoint[0], intersectPoint[1]);
                double ItoB = Geometry.length(intersectPoint[0], intersectPoint[1], temp.xpoints[j+1], temp.ypoints[j+1]);
                double actualDistance;

                //The intersecting point is not on the segment
                if (AtoI > AtoB || ItoB > AtoB)
                {
                    actualDistance = Math.min(Geometry.length(temp.xpoints[j], temp.ypoints[j], p.x, p.y),
                                Geometry.length(p.x, p.y, temp.xpoints[j+1], temp.ypoints[j+1]));
                }
                //The intersecting line is on the segment
                else
                {
                    actualDistance = Geometry.length(intersectPoint[0], intersectPoint[1], p.x, p.y);
                }

                if (actualDistance < minSegmentDistance)
                    minSegmentDistance = actualDistance;
            }

            if (minSegmentDistance < maxDistance && minSegmentDistance < minStrokeDistance)
            {
                minStrokeDistance = minSegmentDistance;
                closestStroke = strokes[i];
            }

        }
    }
    return closestStroke;
}