@Override
  protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
    selectionWidget.setVisible(state.isSelected());
    if (state.isSelected()) {
      selectionWidget.updateBounds();
    }
    // setBorder(  ? getSelectedBorder() : getNormalBorder());
    // showHandles(state.isSelected());

  }
 @Override
 public void unsetHovering(Widget widget) {
   if (widget != null) {
     widget.setBackground(scene.getLookFeel().getBackground(ObjectState.createNormal()));
     widget.setForeground(new Color(0, 0, 0, 0));
     CustomPortInteractor port = (CustomPortInteractor) widget;
     port.setOver(false);
   }
 }
 @Override
 public void setHovering(Widget widget) {
   if (widget != null) {
     ObjectState state = ObjectState.createNormal().deriveSelected(true);
     widget.setBackground(scene.getLookFeel().getBackground(state));
     widget.setForeground(Color.yellow);
     CustomPortInteractor port = (CustomPortInteractor) widget;
     port.setOver(true);
   }
 }
  public JRDesignElementWidget(AbstractReportObjectScene scene, JRDesignElement element) {
    super(scene);
    this.element = element;
    setBorder(new SimpleLineBorder(this));
    updateBounds();

    try {
      if (crosstabImage == null)
        crosstabImage =
            new javax.swing.ImageIcon(
                getClass()
                    .getResource("/com/jaspersoft/ireport/designer/resources/crosstab-32.png"));
      if (subreportImage == null)
        subreportImage =
            new javax.swing.ImageIcon(
                getClass()
                    .getResource("/com/jaspersoft/ireport/designer/resources/subreport-32.png"));
      if (multiaxisImage == null)
        multiaxisImage =
            new javax.swing.ImageIcon(
                getClass()
                    .getResource("/com/jaspersoft/ireport/designer/resources/chartaxis-32.png"));
      if (genericElementImage == null)
        genericElementImage =
            new javax.swing.ImageIcon(
                getClass()
                    .getResource(
                        "/com/jaspersoft/ireport/designer/resources/genericelement-48.png"));
    } catch (Exception ex) {
    }

    selectionWidget = new SelectionWidget(scene, this);
    notifyStateChanged(null, ObjectState.createNormal());
    selectionWidget.addDependency(
        new Dependency() {

          public void revalidateDependency() {
            // setPreferredLocation(selectionWidget.getPreferredLocation() );
            // setPreferredBounds(selectionWidget.getPreferredBounds());
            // System.out.println("Revaludated");
          }
        });

    element.getEventSupport().addPropertyChangeListener(this);

    if (element instanceof JRDesignGraphicElement) {
      JRDesignGraphicElement gele = (JRDesignGraphicElement) element;
      ((JRBasePen) gele.getLinePen()).getEventSupport().addPropertyChangeListener(this);
    }

    if (element instanceof JRBoxContainer) {
      JRBoxContainer boxcontainer = (JRBoxContainer) element;
      JRBaseLineBox baseBox = (JRBaseLineBox) boxcontainer.getLineBox();
      baseBox.getEventSupport().addPropertyChangeListener(this);
      ((JRBasePen) baseBox.getPen()).getEventSupport().addPropertyChangeListener(this);
      ((JRBasePen) baseBox.getTopPen()).getEventSupport().addPropertyChangeListener(this);
      ((JRBasePen) baseBox.getBottomPen()).getEventSupport().addPropertyChangeListener(this);
      ((JRBasePen) baseBox.getLeftPen()).getEventSupport().addPropertyChangeListener(this);
      ((JRBasePen) baseBox.getRightPen()).getEventSupport().addPropertyChangeListener(this);
    }

    if (element instanceof JRDesignTextElement) {
      ((JRBaseParagraph) ((JRDesignTextElement) element).getParagraph())
          .getEventSupport()
          .addPropertyChangeListener(this);
    }
  }