Пример #1
0
 @Override
 protected Image getImage() {
   if (getWidgetModel() instanceof DisplayModel) return super.getImage();
   String typeID = getWidgetModel().getTypeID();
   WidgetDescriptor widgetDescriptor = WidgetsService.getInstance().getWidgetDescriptor(typeID);
   Image image =
       CustomMediaFactory.getInstance()
           .getImageFromPlugin(widgetDescriptor.getPluginId(), widgetDescriptor.getIconPath());
   return image;
 }
  /**
   * initialize the figure
   *
   * @param figure
   */
  protected void initFigure(final IFigure figure) {
    if (figure == null)
      throw new IllegalArgumentException("Editpart does not provide a figure!"); // $NON-NLS-1$
    Set<String> allPropIds = getWidgetModel().getAllPropertyIDs();
    if (allPropIds.contains(AbstractWidgetModel.PROP_COLOR_BACKGROUND))
      figure.setBackgroundColor(
          CustomMediaFactory.getInstance().getColor(getWidgetModel().getBackgroundColor()));

    if (allPropIds.contains(AbstractWidgetModel.PROP_COLOR_FOREGROUND))
      figure.setForegroundColor(
          CustomMediaFactory.getInstance().getColor(getWidgetModel().getForegroundColor()));

    if (allPropIds.contains(AbstractWidgetModel.PROP_FONT))
      figure.setFont(getWidgetModel().getFont().getSWTFont());

    if (allPropIds.contains(AbstractWidgetModel.PROP_VISIBLE))
      figure.setVisible(
          getExecutionMode() == ExecutionMode.RUN_MODE ? getWidgetModel().isVisible() : true);

    if (allPropIds.contains(AbstractWidgetModel.PROP_ENABLED))
      figure.setEnabled(getWidgetModel().isEnabled());

    if (allPropIds.contains(AbstractWidgetModel.PROP_WIDTH)
        && allPropIds.contains(AbstractWidgetModel.PROP_HEIGHT))
      figure.setSize(getWidgetModel().getSize());

    if (allPropIds.contains(AbstractWidgetModel.PROP_BORDER_COLOR)
        && allPropIds.contains(AbstractWidgetModel.PROP_BORDER_STYLE)
        && allPropIds.contains(AbstractWidgetModel.PROP_BORDER_WIDTH))
      figure.setBorder(
          BorderFactory.createBorder(
              getWidgetModel().getBorderStyle(),
              getWidgetModel().getBorderWidth(),
              getWidgetModel().getBorderColor(),
              getWidgetModel().getName()));

    if (allPropIds.contains(AbstractWidgetModel.PROP_TOOLTIP)) {
      if (!getWidgetModel().getTooltip().equals("")) { // $NON-NLS-1$
        tooltipLabel = new TooltipLabel(getWidgetModel());
        figure.setToolTip(tooltipLabel);
      }
    }
  }
Пример #3
0
    @Override
    protected void paintClientArea(Graphics graphics) {
      if (support3d == null) support3d = GraphicsUtil.testPatternSupported(graphics);
      Rectangle clientArea = getClientArea();
      Rectangle square =
          new Rectangle(
              clientArea.x,
              clientArea.y + clientArea.height / 2 - BOX_SIZE / 2,
              BOX_SIZE,
              BOX_SIZE);
      graphics.pushState();
      if (support3d)
        graphics.setBackgroundPattern(
            GraphicsUtil.createScaledPattern(
                graphics,
                Display.getCurrent(),
                square.x,
                square.y + 1,
                square.x,
                square.y + square.height,
                ColorConstants.white,
                graphics.getBackgroundColor()));
      graphics.fillRoundRectangle(square, 4, 4);
      graphics.setForegroundColor(CustomMediaFactory.getInstance().getColor(130, 130, 130));
      graphics.drawRoundRectangle(square, 4, 4);

      if (boolValue) {
        graphics.translate(square.x, square.y);
        graphics.setLineWidth(3);
        graphics.setForegroundColor(selectedColor);

        graphics.drawPolyline(
            new int[] {
              3,
              (int) (BOX_SIZE * 0.45),
              (int) (BOX_SIZE * 0.45),
              BOX_SIZE * 3 / 4 - 1,
              BOX_SIZE - 2,
              3
            });
      }
      graphics.popState();
      Dimension textSize = FigureUtilities.getTextExtents(text, graphics.getFont());

      if (!isEnabled()) {
        graphics.translate(1, 1);
        graphics.setForegroundColor(ColorConstants.buttonLightest);
        graphics.drawText(text, square.getRight().getTranslated(GAP, -textSize.height / 2));
        graphics.translate(-1, -1);
        graphics.setForegroundColor(ColorConstants.buttonDarker);
      }
      graphics.drawText(text, square.getRight().getTranslated(GAP, -textSize.height / 2));

      super.paintClientArea(graphics);
    }
Пример #4
0
 /** @param offColor the offColor to set */
 public synchronized void setOffColor(Color offColor) {
   if (this.offColor != null && this.offColor.equals(offColor)) {
     return;
   }
   if ((offColor.getRed() << 16 | offColor.getGreen() << 8 | offColor.getBlue()) == 0xFFFFFF) {
     this.offColor = CustomMediaFactory.getInstance().getColor(new RGB(255, 255, 254));
   } else {
     this.offColor = offColor;
   }
   repaint();
 }
 /**
  * Sets those properties on the figure that are defined in the {@link AbstractBoolFigure} base
  * class. This method is provided for the convenience of subclasses, which can call this method in
  * their implementation of {@link AbstractBaseEditPart#doCreateFigure()}.
  *
  * @param figure the figure.
  * @param model the model.
  */
 protected void initializeCommonFigureProperties(
     final AbstractBoolFigure figure, final AbstractBoolWidgetModel model) {
   if (model.getDataType() == 0) figure.setBit(model.getBit());
   else figure.setBit(-1);
   updatePropSheet(model.getDataType());
   figure.setShowBooleanLabel(model.isShowBoolLabel());
   figure.setOnLabel(model.getOnLabel());
   figure.setOffLabel(model.getOffLabel());
   figure.setOnColor(model.getOnColor());
   figure.setOffColor(model.getOffColor());
   figure.setFont(CustomMediaFactory.getInstance().getFont(model.getFont().getFontData()));
   figure.setBoolLabelPosition(model.getBoolLabelPosition());
 }
Пример #6
0
 private void setTabFigureProperty(int index, TabProperty tabProperty, final Object newValue) {
   Label label = getTabFigure().getTabLabel(index);
   switch (tabProperty) {
     case TITLE:
       label.setText((String) newValue);
       updateTabAreaSize();
       break;
     case FONT:
       label.setFont(((OPIFont) newValue).getSWTFont());
       updateTabAreaSize();
       break;
     case BACKCOLOR:
       getTabFigure().setTabColor(index, ((OPIColor) newValue).getSWTColor());
       break;
     case FORECOLOR:
       label.setForegroundColor(
           CustomMediaFactory.getInstance().getColor(((OPIColor) newValue).getRGBValue()));
       break;
     case ENABLED:
       getTabFigure().setTabEnabled(index, (Boolean) newValue);
       break;
     case ICON_PATH:
       getTabFigure()
           .setIconPath(
               index,
               getWidgetModel().toAbsolutePath((IPath) newValue),
               new IJobErrorHandler() {
                 public void handleError(Exception e) {
                   String message = "Failed to load image from " + newValue + "\n" + e;
                   Activator.getLogger().log(Level.WARNING, message, e);
                   ConsoleService.getInstance().writeError(message);
                 }
               });
       break;
     default:
       break;
   }
 }
Пример #7
0
/**
 * A tank figure
 *
 * @author Xihui Chen
 */
public class TankFigure extends AbstractLinearMarkedFigure {

  private static final Color WHITE_COLOR =
      CustomMediaFactory.getInstance().getColor(CustomMediaFactory.COLOR_WHITE);
  private static final Color GRAY_COLOR =
      CustomMediaFactory.getInstance().getColor(CustomMediaFactory.COLOR_GRAY);

  private static final Color BLUE_COLOR =
      CustomMediaFactory.getInstance().getColor(CustomMediaFactory.COLOR_BLUE);

  private boolean effect3D = true;
  private Tank tank;
  private Color fillColor = BLUE_COLOR;

  private Color fillBackgroundColor = GRAY_COLOR;

  public TankFigure() {
    super();
    ((LinearScale) scale).setOrientation(Orientation.VERTICAL);
    scale.setScaleLineVisible(false);

    tank = new Tank();
    setLayoutManager(new TankLayout());

    add(scale, TankLayout.SCALE);
    add(marker, TankLayout.MARKERS);
    add(tank, TankLayout.TANK);
  }

  /** @return the fillBackgroundColor */
  public Color getFillBackgroundColor() {
    return fillBackgroundColor;
  }

  /** @return the fillColor */
  public Color getFillColor() {
    return fillColor;
  }

  /** @return the effect3D */
  public boolean isEffect3D() {
    return effect3D;
  }

  @Override
  public boolean isOpaque() {
    return false;
  }

  /** @param effect3D the effect3D to set */
  public void setEffect3D(boolean effect3D) {
    if (this.effect3D == effect3D) return;
    this.effect3D = effect3D;
    repaint();
  }

  /** @param fillBackgroundColor the fillBackgroundColor to set */
  public void setFillBackgroundColor(Color fillBackgroundColor) {
    if (this.fillBackgroundColor != null && this.fillBackgroundColor.equals(fillBackgroundColor))
      return;
    this.fillBackgroundColor = fillBackgroundColor;
    repaint();
  }

  /** @param fillColor the fillColor to set */
  public void setFillColor(Color fillColor) {
    if (this.fillColor != null && this.fillColor.equals(fillColor)) return;
    this.fillColor = fillColor;
    repaint();
  }

  @Override
  public void setForegroundColor(Color fg) {
    super.setForegroundColor(fg);
  }

  class Tank extends RoundedRectangle {
    private final Color EFFECT3D_OUTLINE_COLOR =
        CustomMediaFactory.getInstance().getColor(new RGB(160, 160, 160));
    private static final int DEFAULT_CORNER = 15;
    private Boolean support3d;

    public Tank() {
      super();
      setOutline(true);
    }

    @Override
    protected void fillShape(Graphics graphics) {

      int fill_corner = DEFAULT_CORNER;
      // If this is more close to 1/2, more light the tank will be.
      double intersectFactor = 11d / 20d;
      if (bounds.width < 2 * DEFAULT_CORNER) intersectFactor = 12d / 20d;
      int rectWidth = (int) (bounds.width * intersectFactor);
      if (fill_corner > (2 * rectWidth - (bounds.width - 2 * getLineWidth())))
        fill_corner = 2 * rectWidth - bounds.width;

      corner.height = fill_corner;
      corner.width = fill_corner;
      graphics.setAntialias(SWT.ON);
      int valuePosition = ((LinearScale) scale).getValuePosition(getCoercedValue(), false);
      if (support3d == null) support3d = GraphicsUtil.testPatternSupported(graphics);

      if (effect3D && support3d) {
        graphics.setBackgroundColor(WHITE_COLOR);
        super.fillShape(graphics);
        // fill background
        Rectangle leftRectangle = new Rectangle(bounds.x, bounds.y, rectWidth, bounds.height);
        Pattern leftGradientPattern =
            GraphicsUtil.createScaledPattern(
                graphics,
                Display.getCurrent(),
                leftRectangle.x,
                leftRectangle.y,
                leftRectangle.x + leftRectangle.width + 2,
                leftRectangle.y,
                fillBackgroundColor,
                255,
                WHITE_COLOR,
                0);
        graphics.setBackgroundPattern(leftGradientPattern);
        graphics.fillRoundRectangle(leftRectangle, corner.width, corner.height);
        Rectangle rightRectangle =
            new Rectangle(bounds.x + bounds.width - rectWidth, bounds.y, rectWidth, bounds.height);
        Pattern rightGradientPattern =
            GraphicsUtil.createScaledPattern(
                graphics,
                Display.getCurrent(),
                rightRectangle.x - 2,
                rightRectangle.y,
                rightRectangle.x + rightRectangle.width,
                rightRectangle.y,
                WHITE_COLOR,
                0,
                fillBackgroundColor,
                255);
        graphics.setBackgroundPattern(rightGradientPattern);
        graphics.fillRoundRectangle(rightRectangle, corner.width, corner.height);
        leftGradientPattern.dispose();
        rightGradientPattern.dispose();

        // fill value
        graphics.setBackgroundColor(WHITE_COLOR);
        int fillHeight = bounds.height - (valuePosition - bounds.y) - getLineWidth();
        if (fillHeight > 0) {
          graphics.fillRoundRectangle(
              new Rectangle(bounds.x, valuePosition, bounds.width, fillHeight),
              fill_corner,
              fill_corner);
          leftRectangle = new Rectangle(bounds.x, valuePosition, rectWidth, fillHeight);
          leftGradientPattern =
              GraphicsUtil.createScaledPattern(
                  graphics,
                  Display.getCurrent(),
                  leftRectangle.x,
                  leftRectangle.y,
                  leftRectangle.x + leftRectangle.width + 2,
                  leftRectangle.y,
                  fillColor,
                  255,
                  WHITE_COLOR,
                  0);
          graphics.setBackgroundPattern(leftGradientPattern);
          graphics.fillRoundRectangle(leftRectangle, fill_corner, fill_corner);

          rightRectangle =
              new Rectangle(
                  bounds.x + bounds.width - rectWidth, valuePosition, rectWidth, fillHeight);
          rightGradientPattern =
              GraphicsUtil.createScaledPattern(
                  graphics,
                  Display.getCurrent(),
                  rightRectangle.x - 2,
                  rightRectangle.y,
                  rightRectangle.x + rightRectangle.width,
                  rightRectangle.y,
                  WHITE_COLOR,
                  0,
                  fillColor,
                  255);
          graphics.setBackgroundPattern(rightGradientPattern);
          graphics.fillRoundRectangle(rightRectangle, fill_corner, fill_corner);

          leftGradientPattern.dispose();
          rightGradientPattern.dispose();
        }
        graphics.setForegroundColor(EFFECT3D_OUTLINE_COLOR);

      } else {
        graphics.setBackgroundColor(fillBackgroundColor);
        super.fillShape(graphics);
        graphics.setBackgroundColor(fillColor);
        graphics.fillRoundRectangle(
            new Rectangle(
                bounds.x + lineWidth,
                valuePosition,
                bounds.width - 2 * lineWidth,
                bounds.height - (valuePosition - bounds.y)),
            fill_corner,
            fill_corner);
        //        graphics.setForegroundColor(outlineColor);
      }
    }
  }

  static class TankLayout extends AbstractLayout {

    /** Used as a constraint for the scale. */
    public static final String SCALE = "scale"; // $NON-NLS-1$
    /** Used as a constraint for the pipe indicator. */
    public static final String TANK = "tank"; // $NON-NLS-1$
    /** Used as a constraint for the alarm ticks */
    public static final String MARKERS = "markers"; // $NON-NLS-1$

    private LinearScale scale;
    private LinearScaledMarker marker;
    private Tank tank;

    @Override
    protected Dimension calculatePreferredSize(IFigure container, int w, int h) {
      Insets insets = container.getInsets();
      Dimension d = new Dimension(64, 4 * 64);
      d.expand(insets.getWidth(), insets.getHeight());
      return d;
    }

    public void layout(IFigure container) {
      Rectangle area = container.getClientArea();
      area.height -= 1;
      Dimension scaleSize = new Dimension(0, 0);
      Dimension markerSize = new Dimension(0, 0);

      if (scale != null) {
        if (scale.isVisible()) {
          scaleSize = scale.getPreferredSize(-1, area.height);
          scale.setBounds(new Rectangle(area.x, area.y, scaleSize.width, scaleSize.height));
        } else {
          scaleSize = scale.getPreferredSize(-1, area.height + 2 * scale.getMargin());
          scale.setBounds(
              new Rectangle(area.x, area.y - scale.getMargin(), scaleSize.width, scaleSize.height));
          scaleSize.height = 0;
          scaleSize.width = 0;
        }
      }

      if (marker != null && marker.isVisible()) {
        markerSize = marker.getPreferredSize();
        marker.setBounds(
            new Rectangle(
                area.x + area.width - markerSize.width,
                marker.getScale().getBounds().y,
                markerSize.width,
                markerSize.height));
      }

      if (tank != null) {
        tank.setBounds(
            new Rectangle(
                area.x + scaleSize.width,
                scale.getValuePosition(scale.getRange().getUpper(), false),
                area.width - scaleSize.width - markerSize.width,
                scale.getTickLength() + tank.getLineWidth()));
      }
    }

    @Override
    public void setConstraint(IFigure child, Object constraint) {
      if (constraint.equals(SCALE)) scale = (LinearScale) child;
      else if (constraint.equals(MARKERS)) marker = (LinearScaledMarker) child;
      else if (constraint.equals(TANK)) tank = (Tank) child;
    }
  }
}
Пример #8
0
  class Tank extends RoundedRectangle {
    private final Color EFFECT3D_OUTLINE_COLOR =
        CustomMediaFactory.getInstance().getColor(new RGB(160, 160, 160));
    private static final int DEFAULT_CORNER = 15;
    private Boolean support3d;

    public Tank() {
      super();
      setOutline(true);
    }

    @Override
    protected void fillShape(Graphics graphics) {

      int fill_corner = DEFAULT_CORNER;
      // If this is more close to 1/2, more light the tank will be.
      double intersectFactor = 11d / 20d;
      if (bounds.width < 2 * DEFAULT_CORNER) intersectFactor = 12d / 20d;
      int rectWidth = (int) (bounds.width * intersectFactor);
      if (fill_corner > (2 * rectWidth - (bounds.width - 2 * getLineWidth())))
        fill_corner = 2 * rectWidth - bounds.width;

      corner.height = fill_corner;
      corner.width = fill_corner;
      graphics.setAntialias(SWT.ON);
      int valuePosition = ((LinearScale) scale).getValuePosition(getCoercedValue(), false);
      if (support3d == null) support3d = GraphicsUtil.testPatternSupported(graphics);

      if (effect3D && support3d) {
        graphics.setBackgroundColor(WHITE_COLOR);
        super.fillShape(graphics);
        // fill background
        Rectangle leftRectangle = new Rectangle(bounds.x, bounds.y, rectWidth, bounds.height);
        Pattern leftGradientPattern =
            GraphicsUtil.createScaledPattern(
                graphics,
                Display.getCurrent(),
                leftRectangle.x,
                leftRectangle.y,
                leftRectangle.x + leftRectangle.width + 2,
                leftRectangle.y,
                fillBackgroundColor,
                255,
                WHITE_COLOR,
                0);
        graphics.setBackgroundPattern(leftGradientPattern);
        graphics.fillRoundRectangle(leftRectangle, corner.width, corner.height);
        Rectangle rightRectangle =
            new Rectangle(bounds.x + bounds.width - rectWidth, bounds.y, rectWidth, bounds.height);
        Pattern rightGradientPattern =
            GraphicsUtil.createScaledPattern(
                graphics,
                Display.getCurrent(),
                rightRectangle.x - 2,
                rightRectangle.y,
                rightRectangle.x + rightRectangle.width,
                rightRectangle.y,
                WHITE_COLOR,
                0,
                fillBackgroundColor,
                255);
        graphics.setBackgroundPattern(rightGradientPattern);
        graphics.fillRoundRectangle(rightRectangle, corner.width, corner.height);
        leftGradientPattern.dispose();
        rightGradientPattern.dispose();

        // fill value
        graphics.setBackgroundColor(WHITE_COLOR);
        int fillHeight = bounds.height - (valuePosition - bounds.y) - getLineWidth();
        if (fillHeight > 0) {
          graphics.fillRoundRectangle(
              new Rectangle(bounds.x, valuePosition, bounds.width, fillHeight),
              fill_corner,
              fill_corner);
          leftRectangle = new Rectangle(bounds.x, valuePosition, rectWidth, fillHeight);
          leftGradientPattern =
              GraphicsUtil.createScaledPattern(
                  graphics,
                  Display.getCurrent(),
                  leftRectangle.x,
                  leftRectangle.y,
                  leftRectangle.x + leftRectangle.width + 2,
                  leftRectangle.y,
                  fillColor,
                  255,
                  WHITE_COLOR,
                  0);
          graphics.setBackgroundPattern(leftGradientPattern);
          graphics.fillRoundRectangle(leftRectangle, fill_corner, fill_corner);

          rightRectangle =
              new Rectangle(
                  bounds.x + bounds.width - rectWidth, valuePosition, rectWidth, fillHeight);
          rightGradientPattern =
              GraphicsUtil.createScaledPattern(
                  graphics,
                  Display.getCurrent(),
                  rightRectangle.x - 2,
                  rightRectangle.y,
                  rightRectangle.x + rightRectangle.width,
                  rightRectangle.y,
                  WHITE_COLOR,
                  0,
                  fillColor,
                  255);
          graphics.setBackgroundPattern(rightGradientPattern);
          graphics.fillRoundRectangle(rightRectangle, fill_corner, fill_corner);

          leftGradientPattern.dispose();
          rightGradientPattern.dispose();
        }
        graphics.setForegroundColor(EFFECT3D_OUTLINE_COLOR);

      } else {
        graphics.setBackgroundColor(fillBackgroundColor);
        super.fillShape(graphics);
        graphics.setBackgroundColor(fillColor);
        graphics.fillRoundRectangle(
            new Rectangle(
                bounds.x + lineWidth,
                valuePosition,
                bounds.width - 2 * lineWidth,
                bounds.height - (valuePosition - bounds.y)),
            fill_corner,
            fill_corner);
        //        graphics.setForegroundColor(outlineColor);
      }
    }
  }
Пример #9
0
/**
 * A rectangle figure.
 *
 * @author Sven Wende (original author), Xihui Chen (since import from SDS 2009/10)
 */
public final class OPIRectangleFigure extends RectangleFigure implements Introspectable {
  /** The fill grade (0 - 100%). */
  private double fill = 100;

  /** The orientation (horizontal==true | vertical==false). */
  private boolean horizontalFill = true;

  /** The transparent state of the background. */
  private boolean transparent = false;

  private Color lineColor =
      CustomMediaFactory.getInstance().getColor(CustomMediaFactory.COLOR_PURPLE);

  private Color backGradientStartColor = ColorConstants.white;
  private Color foreGradientStartColor = ColorConstants.white;
  private boolean gradient = false;
  private boolean useAdvancedGraphics = GraphicsUtil.useAdvancedGraphics();

  /** {@inheritDoc} */
  @Override
  protected synchronized void fillShape(final Graphics graphics) {
    Rectangle figureBounds = getClientArea();
    if (!transparent) {
      if (isEnabled()) graphics.setBackgroundColor(getBackgroundColor());
      if (gradient && useAdvancedGraphics) {
        graphics.setForegroundColor(backGradientStartColor);
        graphics.fillGradient(figureBounds, horizontalFill);
      } else graphics.fillRectangle(figureBounds);
    }
    if (getFill() > 0) {
      if (isEnabled()) graphics.setBackgroundColor(getForegroundColor());
      Rectangle fillRectangle;
      if (horizontalFill) {
        int newW = (int) Math.round(figureBounds.width * (getFill() / 100));
        fillRectangle = new Rectangle(figureBounds.x, figureBounds.y, newW, figureBounds.height);
      } else {
        int newH = (int) Math.round(figureBounds.height * (getFill() / 100));
        fillRectangle =
            new Rectangle(
                figureBounds.x,
                figureBounds.y + figureBounds.height - newH,
                figureBounds.width,
                newH);
      }
      if (gradient && useAdvancedGraphics) {
        graphics.setForegroundColor(foreGradientStartColor);
        graphics.fillGradient(fillRectangle, horizontalFill);
      } else graphics.fillRectangle(fillRectangle);
    }
  }

  public BeanInfo getBeanInfo() throws IntrospectionException {
    return new ShapeWidgetIntrospector().getBeanInfo(this.getClass());
  }

  /**
   * Gets the fill grade.
   *
   * @return the fill grade
   */
  public double getFill() {
    return fill;
  }

  /** @return the lineColor */
  public Color getLineColor() {
    return lineColor;
  }

  /**
   * Gets the transparent state of the background.
   *
   * @return the transparent state of the background
   */
  public boolean getTransparent() {
    return transparent;
  }

  /**
   * Gets the orientation (horizontal==true | vertical==false).
   *
   * @return boolean The orientation
   */
  public boolean isHorizontalFill() {
    return horizontalFill;
  }

  /** @return the gradientStartColor */
  public Color getBackGradientStartColor() {
    return backGradientStartColor;
  }

  public Color getForeGradientStartColor() {
    return foreGradientStartColor;
  }

  /** @return the gradient */
  public boolean isGradient() {
    return gradient;
  }

  /** @param gradient the gradient to set */
  public void setGradient(boolean gradient) {
    this.gradient = gradient;
    repaint();
  }

  /**
   * Set gradient start color.
   *
   * @param gradientStartColor
   */
  public void setBackGradientStartColor(Color gradientStartColor) {
    this.backGradientStartColor = gradientStartColor;
    repaint();
  }

  public void setForeGradientStartColor(Color foreGradientStartColor) {
    this.foreGradientStartColor = foreGradientStartColor;
    repaint();
  }

  /** @see Shape#outlineShape(Graphics) */
  protected void outlineShape(Graphics graphics) {
    float lineInset = Math.max(1.0f, getLineWidth()) / 2.0f;
    int inset1 = (int) Math.floor(lineInset);
    int inset2 = (int) Math.ceil(lineInset);

    Rectangle r = Draw2dSingletonUtil.getRectangle().setBounds(getClientArea());
    r.x += inset1;
    r.y += inset1;
    r.width -= inset1 + inset2;
    r.height -= inset1 + inset2;
    if (isEnabled()) graphics.setForegroundColor(lineColor);
    graphics.drawRectangle(r);
  }

  /**
   * Sets the fill grade.
   *
   * @param fill the fill grade.
   */
  public void setFill(final double fill) {
    if (this.fill == fill) return;
    this.fill = fill;
    repaint();
  }

  /**
   * Sets the orientation (horizontal==true | vertical==false).
   *
   * @param horizontal The orientation.
   */
  public void setHorizontalFill(final boolean horizontal) {
    if (this.horizontalFill == horizontal) return;
    this.horizontalFill = horizontal;
    repaint();
  }

  /** @param lineColor the lineColor to set */
  public void setLineColor(Color lineColor) {
    if (this.lineColor != null && this.lineColor.equals(lineColor)) return;
    this.lineColor = lineColor;
    repaint();
  }

  /**
   * Sets the transparent state of the background.
   *
   * @param transparent the transparent state.
   */
  public void setTransparent(final boolean transparent) {
    if (this.transparent == transparent) return;
    this.transparent = transparent;
    repaint();
  }
}