Ejemplo n.º 1
0
  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;
    }
  }
Ejemplo n.º 2
0
  private Component createValueLabel(DetailsDecoration property, int maxLength) {

    String value = property.getFormatedValue();
    boolean abbreviate = (value.length() > maxLength);
    String abbreviatedValue;

    if (value.matches("[0-9\\.]+e-?[0-9]+")) {
      value =
          "<html><body>" + value.replaceAll("e(-?[0-9]+)", "·10<sup>$1</sup>") + "</body></html>";
    }

    if (abbreviate) {
      abbreviatedValue = StringUtils.abbreviate(value, maxLength);
    } else {
      abbreviatedValue = value;
    }

    WebLabel label;
    if (StringUtils.isEmpty(property.getValueLink())) {
      label = new WebLabel(abbreviatedValue);
    } else {
      DetailsWebLinkLabel webLabel = new DetailsWebLinkLabel(abbreviatedValue);
      webLabel.setLink(property.getValueLink(), false);
      label = webLabel;
    }

    SwingUtils.changeFontSize(label, -1);

    if (abbreviate) {
      TooltipManager.setTooltip(label, value, TooltipWay.down, 0);
    }

    label.setCursor(new Cursor(Cursor.HAND_CURSOR));
    label.addMouseListener(new PropertyMouseListener(property));

    if (property.isSelected()) {
      SwingUtils.setBoldFont(label);
    }

    if (property.getBgColor() != null) {
      WebPanel colorBox = new WebPanel();
      colorBox.setPreferredSize(new Dimension(15, 15));
      colorBox.setBackground(property.getBgColor());
      return new GroupPanel(4, colorBox, label);
    }

    label.setForeground(property.isVisible() ? Color.BLACK : Color.lightGray);
    return label;
  }
Ejemplo n.º 3
0
  private Component createNameLabel(DetailsDecoration detail) {

    if (detail instanceof JComponentDetailsDecoration) {
      Component c = createComponentNameLabel((JComponentDetailsDecoration) detail);
      if (c != null) {
        c.setForeground(detail.isVisible() ? Color.BLACK : Color.lightGray);
        return c;
      }
    }

    WebLabel label = new WebLabel(StringUtils.capitalize(detail.getName()), JLabel.TRAILING);

    label.setDrawShade(true);
    SwingUtils.changeFontSize(label, -1);

    if (detail.isSelected()) {
      SwingUtils.setBoldFont(label);
    }

    label.setCursor(new Cursor(Cursor.HAND_CURSOR));
    label.addMouseListener(new PropertyMouseListener(detail));

    if (StringUtils.isNotEmpty(detail.getDescription())) {
      String description =
          "<html><body width=\"300px\">" + detail.getDescription() + "</body></html>";
      TooltipManager.setTooltip(label, description, TooltipWay.down, 0);
    }

    if (!StringUtils.isEmpty(detail.getDescriptionLink())) {
      DetailsWebLinkLabel webLabel = new DetailsWebLinkLabel("", JLabel.TRAILING);
      webLabel.setIcon(IconNames.INFO_ICON);
      webLabel.setLink(detail.getDescriptionLink(), false);
      TooltipManager.setTooltip(webLabel, detail.getDescriptionLink(), TooltipWay.down, 0);
      return new GroupPanel(GroupingType.fillFirst, 5, webLabel, label);
    }

    label.setForeground(detail.isVisible() ? Color.BLACK : Color.lightGray);
    return label;
  }
Ejemplo n.º 4
0
 /** {@inheritDoc} */
 @Override
 public WebTable changeFontSize(final int change) {
   return SwingUtils.changeFontSize(this, change);
 }
Ejemplo n.º 5
0
 /** {@inheritDoc} */
 @Override
 public WebToolTip changeFontSize(int change) {
   return SwingUtils.changeFontSize(this, change);
 }