private static Component createDescription(Example example, ExampleGroup group) {
    Color foreground = group.getPreferredForeground();

    WebLabel titleLabel = new WebLabel(example.getTitle(), JLabel.TRAILING);
    titleLabel.setDrawShade(true);
    titleLabel.setForeground(foreground);
    if (foreground.equals(Color.WHITE)) {
      titleLabel.setShadeColor(Color.BLACK);
    }

    if (example.getDescription() == null) {
      return titleLabel;
    } else {
      WebLabel descriptionLabel = new WebLabel(example.getDescription(), WebLabel.TRAILING);
      descriptionLabel.setForeground(Color.GRAY);
      SwingUtils.changeFontSize(descriptionLabel, -1);

      WebPanel vertical =
          new WebPanel(new VerticalFlowLayout(VerticalFlowLayout.MIDDLE, 0, 0, true, false));
      vertical.setOpaque(false);
      vertical.add(titleLabel);
      vertical.add(descriptionLabel);

      return vertical;
    }
  }
 public List<BufferedImage> getExamples() {
   List<BufferedImage> list = new ArrayList<BufferedImage>();
   for (int i = 0; i < model.size(); i++) {
     Example example = (Example) model.get(i);
     list.add(example.getBufferedImage());
   }
   return list;
 }
  private static Component createPresentationButton(final Example example) {
    final WebToggleButton presentation = new WebToggleButton(presentationIcon);
    presentation.setRolloverDecoratedOnly(true);
    presentation.setFocusable(false);

    presentation.setEnabled(example.isPresentationAvailable());
    TooltipManager.setTooltip(
        presentation,
        presentationIcon,
        example.isPresentationAvailable()
            ? "Show presentation"
            : "There is no presentation available for this component",
        TooltipWay.up);

    if (presentation.isEnabled()) {
      presentation.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              if (presentation.isSelected()) {
                example.startPresentation();
                TooltipManager.setTooltip(
                    presentation, presentationIcon, "Stop presentation", TooltipWay.up);
              } else {
                example.stopPresentation();
                TooltipManager.setTooltip(
                    presentation, presentationIcon, "Show presentation", TooltipWay.up);
              }
            }
          });

      example.doWhenPresentationFinished(
          new Runnable() {
            @Override
            public void run() {
              presentation.setSelected(false);
              TooltipManager.setTooltip(
                  presentation, presentationIcon, "Show presentation", TooltipWay.up);

              ThreadUtils.sleepSafely(250);

              final WebCustomTooltip end =
                  TooltipManager.showOneTimeTooltip(
                      presentation, null, "Presentation has ended", TooltipWay.up);
              WebTimer.delay(
                  1500,
                  new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                      end.closeTooltip();
                    }
                  });
            }
          });
    }

    return new CenterPanel(presentation, false, true);
  }
  private static Component createPreview(WebLookAndFeelDemo owner, Example example) {
    WebPanel previewPanel = new WebPanel();
    previewPanel.setOpaque(false);
    previewPanel.setLayout(
        new TableLayout(
            new double[][] {
              {example.isFillWidth() ? TableLayout.FILL : TableLayout.PREFERRED},
              {TableLayout.FILL, TableLayout.PREFERRED, TableLayout.FILL}
            }));

    previewPanel.add(example.getPreview(owner), "0,1");

    return previewPanel;
  }
 private static Component createMark(final WebLookAndFeelDemo owner, final Example example) {
   final FeatureState fs = example.getFeatureState();
   ImageIcon fsIcon = fs.getIcon();
   final WebLabel featureState = new WebLabel(fsIcon);
   TooltipManager.setTooltip(featureState, fsIcon, fs.getDescription(), TooltipWay.up);
   featureState.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mousePressed(MouseEvent e) {
           owner.showLegend(featureState, fs);
         }
       });
   return new CenterPanel(featureState, true, true);
 }
  private static Component createSourceButton(final WebLookAndFeelDemo owner, Example example) {
    final Class classType = example.getClass();

    WebButton sourceButton = WebButton.createIconWebButton(JarEntry.javaIcon);
    TooltipManager.setTooltip(
        sourceButton, JarEntry.javaIcon, ReflectUtils.getJavaClassName(classType), TooltipWay.up);
    sourceButton.setRolloverDecoratedOnly(true);
    sourceButton.setFocusable(false);

    sourceButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            owner.showSource(classType);
          }
        });

    return new CenterPanel(sourceButton, false, true);
  }
  public static Component createGroupView(WebLookAndFeelDemo owner, ExampleGroup group) {
    // Creating group view
    Component exampleView;
    List<Example> examples = group.getGroupExamples();
    if (group.isSingleExample() && examples.size() == 1) {
      Example example = examples.get(0);
      exampleView = example.getPreview(owner);
    } else {
      final List<Component> preview = new ArrayList<Component>();

      final WebPanel groupPanel =
          new WebPanel() {
            @Override
            public void setEnabled(boolean enabled) {
              for (Component previewComponent : preview) {
                SwingUtils.setEnabledRecursively(previewComponent, enabled);
              }
              super.setEnabled(enabled);
            }
          };
      groupPanel.putClientProperty(SwingUtils.HANDLES_ENABLE_STATE, true);
      groupPanel.setOpaque(false);
      exampleView = groupPanel;

      int rowsAmount = examples.size() > 1 ? examples.size() * 2 - 1 : 1;
      double[] rows = new double[6 + rowsAmount];
      rows[0] = TableLayout.FILL;
      rows[1] = 20;
      rows[2] = TableLayout.PREFERRED;
      for (int i = 3; i < rows.length - 3; i++) {
        rows[i] = TableLayout.PREFERRED;
      }
      rows[rows.length - 3] = TableLayout.PREFERRED;
      rows[rows.length - 2] = 20;
      rows[rows.length - 1] = TableLayout.FILL;

      double[] columns = {
        20,
        1f - group.getContentPartSize(),
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        group.getContentPartSize(),
        20
      };

      TableLayout groupLayout = new TableLayout(new double[][] {columns, rows});
      groupLayout.setHGap(4);
      groupLayout.setVGap(4);
      groupPanel.setLayout(groupLayout);

      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "2,0,2," + (rows.length - 1));
      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "4,0,4," + (rows.length - 1));
      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "6,0,6," + (rows.length - 1));
      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "8,0,8," + (rows.length - 1));

      groupPanel.add(
          group.modifySeparator(createHorizontalSeparator()), "0,2," + (columns.length - 1) + ",2");
      groupPanel.add(
          group.modifySeparator(createHorizontalSeparator()),
          "0," + (rows.length - 3) + "," + (columns.length - 1) + "," + (rows.length - 3));

      int row = 3;
      for (Example example : examples) {
        // Title & description
        groupPanel.add(createDescription(example, group), "1," + row);

        // Marks
        Component mark = createMark(owner, example);
        groupPanel.add(mark, "3," + row);

        // Source code
        Component source = createSourceButton(owner, example);
        groupPanel.add(source, "5," + row);

        // More usage examples
        Component usage = createPresentationButton(example);
        groupPanel.add(usage, "7," + row);

        SwingUtils.equalizeComponentsSize(mark, source, usage);

        // Preview
        Component previewComponent = createPreview(owner, example);
        groupPanel.add(previewComponent, "9," + row);
        preview.add(previewComponent);

        // Rows separator
        if (row > 3) {
          groupPanel.add(
              group.modifySeparator(createHorizontalSeparator()),
              "0," + (row - 1) + "," + (columns.length - 1) + "," + (row - 1),
              0);
        }

        row += 2;
      }
    }

    if (group.isShowWatermark()) {
      WebImage linkImage = new WebImage(logoIcon);
      linkImage.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

      TooltipManager.setTooltip(linkImage, linkIcon, "Library site", TooltipWay.trailing);

      linkImage.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
              WebUtils.browseSiteSafely(WebLookAndFeelDemo.WEBLAF_SITE);
            }
          });

      WebOverlay linkOverlay =
          new WebOverlay(exampleView, linkImage, WebOverlay.LEADING, WebOverlay.BOTTOM);
      linkOverlay.setOverlayMargin(15, 15, 15, 15);
      linkOverlay.setOpaque(false);

      exampleView = linkOverlay;
    }

    return exampleView;
  }