예제 #1
0
  public static synchronized void drawDoubleGradientRect(
      MenuItem item, float x, float y, float width, float height) {
    PGraphicsJava2D buff = item.menu.buff;
    MenuStyle style = item.getStyle();
    Menu menu = item.menu;

    float ro = style.getF("f.roundOff");

    roundRect.setRoundRect(x, y, width, height, ro, ro);

    /*
     * Draw the first gradient: a full-height gradient.
     */
    buff.g2.setPaint(style.getGradient(MenuItem.UP, x, y, x, y + height));
    buff.g2.fill(roundRect);
    /*
     * Draw a translucent gradient on top of the first, starting halfway and
     * going to the bottom.
     */
    Composite oldC = buff.g2.getComposite();
    AlphaComposite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f * menu.alpha);
    buff.g2.setComposite(c);
    buff.g2.setPaint(style.getGradient(MenuItem.UP, x, y + height, x, y + height / 3));
    buff.g2.fillRect((int) x, (int) (y + height / 2), (int) width, (int) height / 2);
    buff.g2.setComposite(oldC);
    /*
     * Finally, draw the stroke on top of everything.
     */
    drawRoundOutline(item, roundRect);
  }
예제 #2
0
  public static synchronized void drawVerticalGradientRect(
      MenuItem item, float x, float y, float width, float height) {
    PGraphicsJava2D buff = item.menu.buff;
    MenuStyle style = item.getStyle();
    Menu menu = item.menu;

    float ro = style.getF("f.roundOff");

    roundRect.setRoundRect(x, y, width, height, ro, ro);
    /*
     * Draw the first gradient: a full-width gradient.
     */
    buff.g2.setPaint(style.getGradient(MenuItem.UP, x, y, x + width, y));
    buff.g2.fill(roundRect);
    /*
     * Draw a translucent gradient on top of the first, starting halfway and
     * going to the bottom.
     */
    Composite oldC = buff.g2.getComposite();
    AlphaComposite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f * menu.alpha);
    buff.g2.setComposite(c);
    buff.g2.setPaint(style.getGradient(MenuItem.UP, x + item.width, y, x + item.width / 3, y));
    buff.g2.fillRect((int) (x + width / 2), (int) (y), (int) (width / 2), (int) height);
    buff.g2.setComposite(oldC);
    /*
     * Finally, draw the stroke on top of everything.
     */
    RenderingHints rh = menu.buff.g2.getRenderingHints();
    buff.g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    buff.g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    buff.g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    buff.g2.setPaint(style.getC("c.foreground"));
    buff.g2.setStroke(new BasicStroke(style.getF("f.strokeWeight")));
    buff.g2.draw(roundRect);
    buff.g2.setRenderingHints(rh);
  }