Esempio n. 1
0
 public void setGradient(MultipleGradientPaint grad) {
   MultipleGradientPaint old = getGradient();
   if (grad instanceof LinearGradientPaint) {
     LinearGradientPaint paint = (LinearGradientPaint) grad;
     this.start = paint.getStartPoint();
     this.end = paint.getEndPoint();
   } else {
     RadialGradientPaint paint = (RadialGradientPaint) grad;
     this.start = paint.getCenterPoint();
     this.end = new Point2D.Double(start.getX(), start.getY() + paint.getRadius());
   }
   this.gradient = grad;
   firePropertyChange("gradient", old, getGradient());
   repaint();
 }
Esempio n. 2
0
  /*
   *
   * @see xtrememp.visual.Visualization#render
   */
  @Override
  public synchronized void render(Graphics g, int width, int height, Context dssContext) {
    float leftLevel = 0.0f;
    float rightLevel = 0.0f;
    int length = dssContext.getLength();
    float[][] channels = dssContext.getDataNormalized();

    for (int a = 0; a < length; a++) {
      leftLevel += Math.abs(channels[0][a]);
      rightLevel += Math.abs(channels[1][a]);
    }

    leftLevel = ((leftLevel * 2.0f) / (float) length);
    rightLevel = ((rightLevel * 2.0f) / (float) length);

    if (leftLevel > 1.0f) {
      leftLevel = 1.0f;
    }

    if (rightLevel > 1.0f) {
      rightLevel = 1.0f;
    }

    if (leftLevel >= (oldLeft - decay)) {
      oldLeft = leftLevel;
    } else {
      oldLeft -= decay;
      if (oldLeft < 0) {
        oldLeft = 0;
      }
    }

    if (rightLevel >= (oldRight - decay)) {
      oldRight = rightLevel;
    } else {
      oldRight -= decay;
      if (oldRight < 0) {
        oldRight = 0;
      }
    }

    g.setColor(Color.black);
    g.fillRect(0, 0, width, height);

    if (lgp == null || lgp.getEndPoint().getX() != width) {
      Point start = new Point(0, 0);
      Point end = new Point(width, 0);
      float[] dist = {0.0f, 0.25f, 0.75f, 1.0f};
      Color[] colors = {Color.green.darker().darker(), Color.green, Color.yellow, Color.red};
      lgp = new LinearGradientPaint(start, end, dist, colors, CycleMethod.REPEAT);
    }

    ((Graphics2D) g).setPaint(lgp);

    int wHeight = (height >> 1) - 8;
    g.fillRect(8, 6, (int) (oldLeft * (float) (width - 32)), wHeight);
    g.fillRect(8, wHeight + 10, (int) (oldRight * (float) (width - 32)), wHeight);
  }
Esempio n. 3
0
 @Override
 public java.awt.PaintContext createContext(
     final java.awt.image.ColorModel COLOR_MODEL,
     final java.awt.Rectangle DEVICE_BOUNDS,
     java.awt.geom.Rectangle2D USER_BOUNDS,
     java.awt.geom.AffineTransform X_FORM,
     java.awt.RenderingHints HINTS) {
   return GRADIENT.createContext(COLOR_MODEL, DEVICE_BOUNDS, USER_BOUNDS, X_FORM, HINTS);
 }
Esempio n. 4
0
 @Override
 public int getTransparency() {
   return GRADIENT.getTransparency();
 }
Esempio n. 5
0
 /**
  * Returns the point where the wrapped java.awt.LinearGradientPaint will stop
  *
  * @return the point where the wrapped java.awt.LinearGradientPaint will stop
  */
 public java.awt.geom.Point2D getEndPoint() {
   return GRADIENT.getEndPoint();
 }