當前位置: 首頁>>代碼示例>>Java>>正文


Java RectF.intersects方法代碼示例

本文整理匯總了Java中android.graphics.RectF.intersects方法的典型用法代碼示例。如果您正苦於以下問題:Java RectF.intersects方法的具體用法?Java RectF.intersects怎麽用?Java RectF.intersects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.RectF的用法示例。


在下文中一共展示了RectF.intersects方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateRectangles

import android.graphics.RectF; //導入方法依賴的package包/類
private void generateRectangles() {
    for (BackportAppointment a : dayAppointments) {
        // Default, left aligned (not shifted) rectangle
        RectF a_rect = layoutRectangle(a);

        // Check for each rects if intersection is present
        boolean check_intersect = true;
        int i = 0;
        start_intersection_check:
        while (check_intersect) {
            for (RectF r : eventRectangles.values()) {
                if (r.contains(a_rect) || RectF.intersects(r, a_rect)) {
                    if (++i > shiftX_max) shiftX_max = i;
                    // shift one unit to the right and start again
                    a_rect.offset(dp(2 * X_OFFSET + X_WIDTH), 0);
                    continue start_intersection_check;
                } // else check next
            }

            // finish
            check_intersect = false;
        }

        eventRectangles.put(a, a_rect);
    }
}
 
開發者ID:dhbw-timetable,項目名稱:dhbw-timetable-android,代碼行數:27,代碼來源:WeekdayView.java

示例2: drawLabel

import android.graphics.RectF; //導入方法依賴的package包/類
/**
 * Draws a text label.
 * 
 * @param canvas the canvas
 * @param labelText the label text
 * @param renderer the renderer
 * @param prevLabelsBounds the previous rendered label bounds
 * @param centerX the round chart center on X axis
 * @param centerY the round chart center on Y axis
 * @param shortRadius the short radius for the round chart
 * @param longRadius the long radius for the round chart
 * @param currentAngle the current angle
 * @param angle the label extra angle
 * @param left the left side
 * @param right the right side
 * @param color the label color
 * @param paint the paint
 * @param line if a line to the label should be drawn
 * @param display display the label anyway
 */
protected void drawLabel(Canvas canvas, String labelText, DefaultRenderer renderer,
    List<RectF> prevLabelsBounds, int centerX, int centerY, float shortRadius, float longRadius,
    float currentAngle, float angle, int left, int right, int color, Paint paint, boolean line,
    boolean display) {
  if (renderer.isShowLabels() || display) {
    paint.setColor(color);
    double rAngle = Math.toRadians(90 - (currentAngle + angle / 2));
    double sinValue = Math.sin(rAngle);
    double cosValue = Math.cos(rAngle);
    int x1 = Math.round(centerX + (float) (shortRadius * sinValue));
    int y1 = Math.round(centerY + (float) (shortRadius * cosValue));
    int x2 = Math.round(centerX + (float) (longRadius * sinValue));
    int y2 = Math.round(centerY + (float) (longRadius * cosValue));

    float size = renderer.getLabelsTextSize();
    float extra = Math.max(size / 2, 10);
    paint.setTextAlign(Align.LEFT);
    if (x1 > x2) {
      extra = -extra;
      paint.setTextAlign(Align.RIGHT);
    }
    float xLabel = x2 + extra;
    float yLabel = y2;
    float width = right - xLabel;
    if (x1 > x2) {
      width = xLabel - left;
    }
    labelText = getFitText(labelText, width, paint);
    float widthLabel = paint.measureText(labelText);
    boolean okBounds = false;
    while (!okBounds && line) {
      boolean intersects = false;
      int length = prevLabelsBounds.size();
      for (int j = 0; j < length && !intersects; j++) {
        RectF prevLabelBounds = prevLabelsBounds.get(j);
        if (prevLabelBounds.intersects(xLabel, yLabel, xLabel + widthLabel, yLabel + size)) {
          intersects = true;
          yLabel = Math.max(yLabel, prevLabelBounds.bottom);
        }
      }
      okBounds = !intersects;
    }

    if (line) {
      y2 = (int) (yLabel - size / 2);
      canvas.drawLine(x1, y1, x2, y2, paint);
      canvas.drawLine(x2, y2, x2 + extra, y2, paint);
    } else {
      paint.setTextAlign(Align.CENTER);
    }
    canvas.drawText(labelText, xLabel, yLabel, paint);
    if (line) {
      prevLabelsBounds.add(new RectF(xLabel, yLabel, xLabel + widthLabel, yLabel + size));
    }
  }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:77,代碼來源:AbstractChart.java

示例3: isVisible

import android.graphics.RectF; //導入方法依賴的package包/類
public boolean isVisible() {
    return RectF.intersects(documentView.getViewRect(), bounds);
}
 
開發者ID:lidong1665,項目名稱:AndroidPDF,代碼行數:4,代碼來源:Page.java

示例4: isVisible

import android.graphics.RectF; //導入方法依賴的package包/類
private boolean isVisible() {
    return RectF.intersects(documentView.getViewRect(), getTargetRectF());
}
 
開發者ID:lidong1665,項目名稱:AndroidPDF,代碼行數:4,代碼來源:PageTreeNode.java


注:本文中的android.graphics.RectF.intersects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。