/** Updates renderer elements view. */
 public void updateFilesView() {
   if (isTilesView()) {
     nameLabel.setHorizontalAlignment(JLabel.LEADING);
     fileList.setFixedCellWidth(tileCellSize.width);
     fileList.setFixedCellHeight(tileCellSize.height);
   } else {
     nameLabel.setHorizontalAlignment(JLabel.CENTER);
     fileList.setFixedCellWidth(iconCellSize.width);
     fileList.setFixedCellHeight(iconCellSize.height);
   }
 }
Ejemplo n.º 2
0
 /**
  * Creates and returns title label.
  *
  * @return created title label
  */
 protected WebLabel createTitleLabel() {
   titleLabel = new WebLabel(titleFormat.format(shownDate));
   titleLabel.setBoldFont();
   titleLabel.setDrawShade(true);
   titleLabel.setHorizontalAlignment(WebLabel.CENTER);
   titleLabel.setVerticalAlignment(WebLabel.CENTER);
   return titleLabel;
 }
  /**
   * Constructs cell renderer for the specified file list.
   *
   * @param fileList file list in which this cell renderer is used
   */
  public WebFileListCellRenderer(final WebFileList fileList) {
    super();

    this.fileList = fileList;

    iconLabel = new WebLabel();
    iconLabel.setHorizontalAlignment(JLabel.CENTER);
    iconLabel.setPreferredSize(new Dimension(imageSide, imageSide));

    nameLabel = new WebLabel();
    nameLabel.setFont(nameLabel.getFont().deriveFont(Font.PLAIN));
    nameLabel.setForeground(Color.BLACK);
    nameLabel.setVerticalAlignment(JLabel.CENTER);

    descriptionLabel = new WebLabel(WebLabel.LEADING);
    descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(Font.PLAIN));
    descriptionLabel.setForeground(Color.GRAY);

    sizeLabel = new WebLabel(WebLabel.LEADING);
    sizeLabel.setFont(sizeLabel.getFont().deriveFont(Font.PLAIN));
    sizeLabel.setForeground(new Color(49, 77, 179));

    setLayout(new FileCellLayout());
    add(iconLabel);
    add(nameLabel);
    add(descriptionLabel);
    add(sizeLabel);

    fileList.addPropertyChangeListener(
        WebLookAndFeel.COMPONENT_ENABLED_PROPERTY,
        new PropertyChangeListener() {
          @Override
          public void propertyChange(final PropertyChangeEvent evt) {
            final boolean enabled = fileList.isEnabled();
            iconLabel.setEnabled(enabled);
            nameLabel.setEnabled(enabled);
            descriptionLabel.setEnabled(enabled);
            sizeLabel.setEnabled(enabled);
          }
        });

    fileList.addPropertyChangeListener(
        WebLookAndFeel.COMPONENT_ORIENTATION_PROPERTY,
        new PropertyChangeListener() {
          @Override
          public void propertyChange(final PropertyChangeEvent evt) {
            final ComponentOrientation orientation = fileList.getComponentOrientation();
            nameLabel.setComponentOrientation(orientation);
            descriptionLabel.setComponentOrientation(orientation);
            sizeLabel.setComponentOrientation(orientation);
          }
        });

    updateFilesView();
  }
Ejemplo n.º 4
0
  /** Updates week headers. */
  protected void updateWeekHeaders() {
    weekHeaders.removeAll();
    for (int i = 1; i <= 7; i++) {
      final int day = startWeekFromSunday ? (i == 1 ? 7 : i - 1) : i;

      final WebLabel dayOfWeekLabel = new WebLabel();
      dayOfWeekLabel.setLanguage("weblaf.ex.calendar.dayOfWeek." + day);
      dayOfWeekLabel.setDrawShade(true);
      dayOfWeekLabel.setHorizontalAlignment(WebLabel.CENTER);
      dayOfWeekLabel.setFontSizeAndStyle(10, Font.BOLD);
      weekHeaders.add(dayOfWeekLabel, (i - 1) * 2 + ",0");

      if (i < 7) {
        weekHeaders.add(new WebSeparator(WebSeparator.VERTICAL), ((i - 1) * 2 + 1) + ",0");
      }
    }
    weekHeaders.revalidate();
  }