示例#1
0
 public RoundRectangle2D evaluate(RoundRectangle2D v0, RoundRectangle2D v1, float fraction) {
   double x = v0.getX() + ((v1.getX() - v0.getX()) * fraction);
   double y = v0.getY() + ((v1.getY() - v0.getY()) * fraction);
   double w = v0.getWidth() + ((v1.getWidth() - v0.getWidth()) * fraction);
   double h = v0.getHeight() + ((v1.getHeight() - v0.getHeight()) * fraction);
   double arcw = v0.getArcWidth() + ((v1.getArcWidth() - v0.getArcWidth()) * fraction);
   double arch = v0.getArcHeight() + ((v1.getArcHeight() - v0.getArcHeight()) * fraction);
   RoundRectangle2D value = (RoundRectangle2D) v0.clone();
   value.setRoundRect(x, y, w, h, arcw, arch);
   return value;
 }
 RoundRectIterator(RoundRectangle2D rr, AffineTransform at) {
   this.x = rr.getX();
   this.y = rr.getY();
   this.w = rr.getWidth();
   this.h = rr.getHeight();
   this.aw = Math.min(w, Math.abs(rr.getArcWidth()));
   this.ah = Math.min(h, Math.abs(rr.getArcHeight()));
   this.affine = at;
   if (aw < 0 || ah < 0) {
     // Don't draw anything...
     index = ctrlpts.length;
   }
 }
 public static void fastFill(Graphics2D g2, RoundRectangle2D r) {
   Rectangle b = r.getBounds();
   g2.fillRoundRect(b.x, b.y, b.width, b.height, (int) r.getArcWidth(), (int) r.getArcHeight());
 }
  // <editor-fold defaultstate="collapsed" desc="Image related">
  private BufferedImage create_LCD_Image(final int WIDTH, final int HEIGHT) {
    if (WIDTH <= 0 || HEIGHT <= 0) {
      return null;
    }

    final BufferedImage IMAGE = UTIL.createImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT);
    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    G2.setRenderingHint(
        RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();

    // Background rectangle
    final Point2D BACKGROUND_START = new Point2D.Double(0.0, 0.0);
    final Point2D BACKGROUND_STOP = new Point2D.Double(0.0, IMAGE_HEIGHT);
    if (BACKGROUND_START.equals(BACKGROUND_STOP)) {
      BACKGROUND_STOP.setLocation(0.0, BACKGROUND_START.getY() + 1);
    }

    final float[] BACKGROUND_FRACTIONS = {0.0f, 0.08f, 0.92f, 1.0f};

    final Color[] BACKGROUND_COLORS = {
      new Color(0.4f, 0.4f, 0.4f, 1.0f),
      new Color(0.5f, 0.5f, 0.5f, 1.0f),
      new Color(0.5f, 0.5f, 0.5f, 1.0f),
      new Color(0.9f, 0.9f, 0.9f, 1.0f)
    };

    final LinearGradientPaint BACKGROUND_GRADIENT =
        new LinearGradientPaint(
            BACKGROUND_START, BACKGROUND_STOP, BACKGROUND_FRACTIONS, BACKGROUND_COLORS);
    // final double BACKGROUND_CORNER_RADIUS = WIDTH * 0.09375;
    final double BACKGROUND_CORNER_RADIUS = WIDTH > HEIGHT ? (HEIGHT * 0.095) : (WIDTH * 0.095);
    final java.awt.geom.RoundRectangle2D BACKGROUND =
        new java.awt.geom.RoundRectangle2D.Double(
            0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, BACKGROUND_CORNER_RADIUS, BACKGROUND_CORNER_RADIUS);
    G2.setPaint(BACKGROUND_GRADIENT);
    G2.fill(BACKGROUND);

    // Foreground rectangle
    final Point2D FOREGROUND_START = new Point2D.Double(0.0, 1.0);
    final Point2D FOREGROUND_STOP = new Point2D.Double(0.0, IMAGE_HEIGHT - 1);
    if (FOREGROUND_START.equals(FOREGROUND_STOP)) {
      FOREGROUND_STOP.setLocation(0.0, FOREGROUND_START.getY() + 1);
    }

    final float[] FOREGROUND_FRACTIONS = {0.0f, 0.03f, 0.49f, 0.5f, 1.0f};

    final Color[] FOREGROUND_COLORS = {
      lcdColor.GRADIENT_START_COLOR,
      lcdColor.GRADIENT_FRACTION1_COLOR,
      lcdColor.GRADIENT_FRACTION2_COLOR,
      lcdColor.GRADIENT_FRACTION3_COLOR,
      lcdColor.GRADIENT_STOP_COLOR
    };

    if (lcdColor == LcdColor.CUSTOM) {
      G2.setPaint(customLcdBackground);
    } else {
      final LinearGradientPaint FOREGROUND_GRADIENT =
          new LinearGradientPaint(
              FOREGROUND_START, FOREGROUND_STOP, FOREGROUND_FRACTIONS, FOREGROUND_COLORS);
      G2.setPaint(FOREGROUND_GRADIENT);
    }
    final double FOREGROUND_CORNER_RADIUS = BACKGROUND.getArcWidth() - 1;
    final java.awt.geom.RoundRectangle2D FOREGROUND =
        new java.awt.geom.RoundRectangle2D.Double(
            1,
            1,
            IMAGE_WIDTH - 2,
            IMAGE_HEIGHT - 2,
            FOREGROUND_CORNER_RADIUS,
            FOREGROUND_CORNER_RADIUS);
    G2.fill(FOREGROUND);

    G2.dispose();

    return IMAGE;
  }