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

  }
  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);
    }
  }