Package org.japura.gui.Gradient

Examples of org.japura.gui.Gradient.Direction


  private void paintGradient(Gradient gradient, Graphics g) {
  Insets insets = getInsets();

  Graphics2D g2d = (Graphics2D) g;
  GradientPaint gp = null;
  Direction direction = gradient.getDirection();
  Color firstColor = gradient.getFirstColor();
  Color secondColor = gradient.getSecondColor();

  int y = insets.top;
  int x = insets.left;
  int w = getWidth() - (insets.left + insets.right);
  int h = getHeight() - (insets.bottom + insets.top);

  if (direction.equals(Direction.TOP_TO_BOTTOM)) {
    gp = new GradientPaint(0, y, firstColor, 0, h, secondColor);
  } else if (direction.equals(Direction.BOTTOM_TO_TOP)) {
    gp = new GradientPaint(0, y, secondColor, 0, h, firstColor);
  } else if (direction.equals(Direction.LEFT_TO_RIGHT)) {
    gp = new GradientPaint(x, 0, firstColor, w, 0, secondColor);
  } else if (direction.equals(Direction.RIGHT_TO_LEFT)) {
    gp = new GradientPaint(x, 0, secondColor, w, 0, firstColor);
  }
  g2d.setPaint(gp);
  g2d.fillRect(x, y, w, h);
  }
View Full Code Here


  int height = getInnerTitlePanel().getHeight() + (2 * titleMargin);

  if (hasTitleBackgroundGradient()) {
    GradientPaint gp = null;
    Gradient gradient = (Gradient) getTitleBackground();
    Direction direction = gradient.getDirection();
    Color firstColor = gradient.getFirstColor();
    Color secondColor = gradient.getSecondColor();

    if (direction.equals(Direction.TOP_TO_BOTTOM)) {
    gp = new GradientPaint(0, y, firstColor, 0, y + height, secondColor);
    } else if (direction.equals(Direction.BOTTOM_TO_TOP)) {
    gp = new GradientPaint(0, y, secondColor, 0, y + height, firstColor);
    } else if (direction.equals(Direction.LEFT_TO_RIGHT)) {
    gp =
      new GradientPaint(insets.left, 0, firstColor, getWidth()
        - (insets.left + insets.right), 0, secondColor);
    } else if (direction.equals(Direction.RIGHT_TO_LEFT)) {
    gp =
      new GradientPaint(insets.left, 0, secondColor, getWidth()
        - (insets.left + insets.right), 0, firstColor);
    }
    g2d.setPaint(gp);
View Full Code Here

TOP

Related Classes of org.japura.gui.Gradient.Direction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.