protected boolean isExpandable() {
   return presenter.isExpandable();
 }
 protected PaletteGrid getGrid() {
   return presenter.getGrid();
 }
 @Override
 public double getHeight() {
   return presenter.computePaletteSize()[1];
 }
  protected IPrimitive<?> createExpandCollapseButton() {
    final boolean isExpanded = presenter.isExpanded();
    final double w = getGrid().getIconSize();
    final double h = getGrid().getIconSize() / 1.5;
    final Rectangle rectangle =
        new Rectangle(w, h).setFillAlpha(0.01).setStrokeWidth(0).setStrokeAlpha(0);
    final Arrow expandArrow =
        new Arrow(
                new Point2D(0, h / 2),
                new Point2D(w, h / 2),
                h / 2,
                h,
                45,
                90,
                ArrowType.AT_END_TAPERED)
            .setFillColor(getArrowOutColor())
            .setFillAlpha(0.5)
            .setVisible(!isExpanded);
    final Arrow collapseArrow =
        new Arrow(
                new Point2D(w, h / 2),
                new Point2D(0, h / 2),
                h / 2,
                h,
                45,
                90,
                ArrowType.AT_END_TAPERED)
            .setFillColor(getArrowOutColor())
            .setFillAlpha(0.5)
            .setVisible(isExpanded);
    handlerRegistrationManager.register(
        rectangle.addNodeMouseClickHandler(
            nodeMouseClickEvent -> {
              if (presenter.isExpanded()) {
                expandArrow.setVisible(true);
                collapseArrow.setVisible(false);
                presenter.collapse();

              } else {
                expandArrow.setVisible(false);
                collapseArrow.setVisible(true);
                presenter.expand();
              }
            }));
    handlerRegistrationManager.register(
        rectangle.addNodeMouseEnterHandler(
            nodeMouseEnterEvent -> {
              stopHoverTimeoutPalette();
              if (presenter.isExpanded()) {
                animate(collapseArrow, getArrowHoverColor(), 1, 1);

              } else {
                animate(expandArrow, getArrowHoverColor(), 1, 1);
              }
            }));
    handlerRegistrationManager.register(
        rectangle.addNodeMouseExitHandler(
            nodeMouseExitEvent -> {
              startHoverTimeoutPalette();
              if (presenter.isExpanded()) {
                animate(collapseArrow, getArrowOutColor(), 0.5, 0.5);

              } else {
                animate(expandArrow, getArrowOutColor(), 0.5, 0.5);
              }
            }));
    return new Group().add(expandArrow).add(collapseArrow).add(rectangle.moveToTop());
  }
 @Override
 public double getWidth() {
   return presenter.computePaletteSize()[0];
 }