Esempio n. 1
0
 protected void fireChangeListeners() {
   if (changeListeners == null) return;
   for (int a = 0; a < changeListeners.size(); a++) {
     ChangeListener l = (ChangeListener) changeListeners.get(a);
     try {
       l.stateChanged(new ChangeEvent(this));
     } catch (RuntimeException e) {
       e.printStackTrace();
     }
   }
 }
Esempio n. 2
0
  /** Updates the FancyShape. */
  void update() { // don't update warning regions here, do it in GraphArea...

    if (getNeedsUpdate()) {

      if (lightSource == TOP) {
        paint =
            new GradientPaint(
                lightBounds.x,
                lightBounds.y,
                color.brighter(),
                lightBounds.x,
                lightBounds.y + lightBounds.height,
                color);
        if (outlineExistence) {
          outlinePaint =
              new GradientPaint(
                  lightBounds.x,
                  lightBounds.y,
                  outlineColor.brighter(),
                  lightBounds.x,
                  lightBounds.y + lightBounds.height,
                  outlineColor);
        }
        warningPaints.removeAllElements();
        if (warningRegions != null) {
          for (int i = 0; i < warningRegions.size(); ++i) {
            Color warningColor = ((WarningRegion) warningRegions.get(i)).getComponentColor();
            warningPaints.add(
                new GradientPaint(
                    lightBounds.x,
                    lightBounds.y,
                    warningColor.brighter(),
                    lightBounds.x,
                    lightBounds.y + lightBounds.height,
                    warningColor));
          }
        }
      } else if (lightSource == BOTTOM) {
        paint =
            new GradientPaint(
                lightBounds.x,
                lightBounds.y,
                color,
                lightBounds.x,
                lightBounds.y + lightBounds.height,
                color.brighter());
        if (outlineExistence) {
          outlinePaint =
              new GradientPaint(
                  lightBounds.x,
                  lightBounds.y,
                  outlineColor,
                  lightBounds.x,
                  lightBounds.y + lightBounds.height,
                  outlineColor.brighter());
        }
        warningPaints.removeAllElements();
        for (int i = 0; i < warningRegions.size(); ++i) {
          Color warningColor = ((WarningRegion) warningRegions.get(i)).getComponentColor();
          warningPaints.add(
              new GradientPaint(
                  lightBounds.x,
                  lightBounds.y,
                  warningColor,
                  lightBounds.x,
                  lightBounds.y + lightBounds.height,
                  warningColor.brighter()));
        }
      } else if (lightSource == LEFT) {

        paint =
            new GradientPaint(
                lightBounds.x,
                lightBounds.y,
                color.brighter(),
                lightBounds.x + lightBounds.width,
                lightBounds.y,
                color);
        if (outlineExistence) {
          outlinePaint =
              new GradientPaint(
                  lightBounds.x,
                  lightBounds.y,
                  outlineColor.brighter(),
                  lightBounds.x + lightBounds.width,
                  lightBounds.y,
                  outlineColor);
        }
        warningPaints.removeAllElements();
        if (warningRegions != null) {
          for (int i = 0; i < warningRegions.size(); ++i) {
            Color warningColor = ((WarningRegion) warningRegions.get(i)).getComponentColor();
            warningPaints.add(
                new GradientPaint(
                    lightBounds.x,
                    lightBounds.y,
                    warningColor.brighter(),
                    lightBounds.x + lightBounds.width,
                    lightBounds.y,
                    warningColor));
          }
        }
      } else if (lightSource == RIGHT) {
        paint =
            new GradientPaint(
                lightBounds.x,
                lightBounds.y,
                color,
                lightBounds.x + lightBounds.width,
                lightBounds.y,
                color.brighter());
        if (outlineExistence) {
          outlinePaint =
              new GradientPaint(
                  lightBounds.x,
                  lightBounds.y,
                  outlineColor,
                  lightBounds.x + lightBounds.width,
                  lightBounds.y,
                  outlineColor.brighter());
        }
        warningPaints.removeAllElements();
        if (warningRegions != null) {
          for (int i = 0; i < warningRegions.size(); ++i) {
            Color warningColor = ((WarningRegion) warningRegions.get(i)).getComponentColor();
            warningPaints.add(
                new GradientPaint(
                    lightBounds.x,
                    lightBounds.y,
                    warningColor,
                    lightBounds.x + lightBounds.width,
                    lightBounds.y,
                    warningColor.brighter()));
          }
        }
      } else {
        paint = color;
        outlinePaint = outlineColor;
        warningPaints.removeAllElements();
        if (warningRegions != null) {
          for (int i = 0; i < warningRegions.size(); ++i) {
            Color warningColor = ((WarningRegion) warningRegions.get(i)).getComponentColor();
            warningPaints.add(warningColor);
          }
        }
      }
      needsUpdate = false;
    }
  }