Пример #1
0
  /** Updates the button. */
  private void updateButton() {
    if (!initialized) return;

    Icon icon = IconManager.instance().getIconForButton(iconName);

    if (icon == null) {
      super.setText(message);

      setVerticalTextPosition(SwingConstants.CENTER);
      setHorizontalTextPosition(SwingConstants.CENTER);

      setContentAreaFilled(true);
      setBorderPainted(true);
      setOpaque(true);

    } else {
      setIcon(icon);

      Icon rollover = IconManager.instance().getIconForButton(rollOverIconName);
      if (rollover == null) {
        rollover = IconManager.instance().getRolloverIconForButton(iconName);
      }
      setRolloverIcon(rollover);

      if (!horizontalText) {
        setVerticalTextPosition(SwingConstants.BOTTOM);
        setHorizontalTextPosition(SwingConstants.CENTER);
      } else {
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.TRAILING);
      }

      if (useTransparentBackground) {
        setBorderPainted(false);
        setOpaque(false);
        setContentAreaFilled(false);
      } else {
        setBorderPainted(true);
        setOpaque(false);
        setContentAreaFilled(true);
      }

      if (!iconOnly
          && UISettings.TEXT_WITH_ICONS.getValue()
          && message != null
          && message.length() > 0) {
        super.setText(message);
        setPreferredSize(null);
      } else {
        super.setText(null);
        int height = icon.getIconHeight();
        int width = icon.getIconWidth();
        if (message == null || message.length() > 0) {
          height += 15;
          width += 15;
        }
        setPreferredSize(new Dimension(height, width));
      }
    }
  }
Пример #2
0
  @Override
  public void onBindViewHolder(WeatherListViewHolder holder, int position) {
    if (isDaily) {
      String day = weatherDailyArrayList.get(position).dayOfWeek;
      String min = weatherDailyArrayList.get(position).temperatureMin;
      String max = weatherDailyArrayList.get(position).temperatureMax;
      String maxTime = weatherDailyArrayList.get(position).temperatureMaxTime;
      String minTime = weatherDailyArrayList.get(position).temperatureMinTime;
      String windSpeed = weatherDailyArrayList.get(position).windSpeed;
      String precipType = weatherDailyArrayList.get(position).precipType;
      String precipChance = weatherDailyArrayList.get(position).precipProbability;
      String summary = weatherDailyArrayList.get(position).summary;
      String icon = weatherDailyArrayList.get(position).iconRef;

      holder.conditionImageView.setImageResource(IconManager.getIconReference(icon));
      holder.dayTextView.setText(day);
      holder.lowTextView.setText("Low: " + min + "\u00B0F @ " + minTime);
      holder.hiTextView.setText("High: " + max + "\u00B0F @ " + maxTime);
      holder.windSpeedTextView.setText("Windspeed: " + windSpeed + "mph");
      holder.precipTypeTextView.setText(
          ((precipType.equals("")) ? "Precipitation" : precipType) + " " + precipChance + "%");
      holder.summaryTextView.setText(summary);
    }

    if (isHourly) {
      String day = weatherHourlyArrayList.get(position).dayOfWeek;
      String windSpeed = weatherHourlyArrayList.get(position).windSpeed;
      String precipType = weatherHourlyArrayList.get(position).precipType;
      String precipChance = weatherHourlyArrayList.get(position).precipProbability;
      String summary = weatherHourlyArrayList.get(position).summary;
      String icon = weatherHourlyArrayList.get(position).iconRef;
      String curTemp = weatherHourlyArrayList.get(position).currentTemp;
      String apparentTemp = weatherHourlyArrayList.get(position).apparentTemp;

      holder.conditionImageView.setImageResource(IconManager.getIconReference(icon));
      holder.dayTextView.setText(day);
      holder.lowTextView.setText("Actual: " + curTemp + "\u00B0F");
      holder.hiTextView.setText("Feels like: " + apparentTemp + "\u00B0F");
      holder.windSpeedTextView.setText("Windspeed: " + windSpeed + "mph");
      holder.precipTypeTextView.setText(
          ((precipType.equals("")) ? "Precipitation" : precipType) + " " + precipChance + "%");
      holder.summaryTextView.setText(summary);
    }

    if (position % 2 == 0)
      holder.weather_list_layout.setBackgroundColor(
          ContextCompat.getColor(context, R.color.colorPrimaryDarkest));
    else
      holder.weather_list_layout.setBackgroundColor(
          ContextCompat.getColor(context, R.color.colorPrimaryDark600));
  }
 public Icon getIcon(File obj) {
   String extension = FilenameUtils.getExtension(obj.getName());
   if (extension != null) {
     return IconManager.instance().getIconForExtension(extension);
   }
   return null;
 }
 @Override
 public Component getListCellRendererComponent(
     JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
   String extension = FilenameUtils.getExtension(value.toString());
   if (extension != null) {
     setIcon(IconManager.instance().getIconForExtension(extension));
   }
   return this;
 }
Пример #5
0
  /**
   * Returns an icon for a given size in pixels
   *
   * @param id the ID of the size of the icon
   * @return the icon for that size in pixels
   */
  public ImageIcon getIcon(final IconSize id) {
    imageIcon = getIcon();

    IconSizeEntry sizeEntry = icons.get(id);
    if (sizeEntry == null) {

      ImageIcon imgIcon = IconManager.createNewScaledIcon(imageIcon, size, id);
      if (id.blackWhite()) {
        imgIcon = IconManager.createBWImage(imgIcon);
      }
      if (id.faded()) {
        imgIcon = IconManager.createFadedImage(imgIcon);
      }
      IconSizeEntry newSizeEntry = new IconSizeEntry(id, imgIcon);
      icons.put(id, newSizeEntry);
      return imgIcon;
    }
    return sizeEntry.getImageIcon();
  }
Пример #6
0
  private void initializeTray() {
    tray =
        new JXTrayIcon(
            IconManager.getIcon("arrow_divide").getImage(),
            Launcher.getName() + " - " + Launcher.getVersion());
    popup = buildPopupMenu();

    tray.setJPopupMenu(popup);
    tray.addActionListener(this);
    tray.setActionCommand("tray");

    SystemTray systemTray = SystemTray.getSystemTray();
    try {
      log.debug("Adding to tray");
      systemTray.add(tray);
    } catch (AWTException e) {
      log.error(e);
    }
    if (Prefs.prefs.at("app.displaywelcome").asBoolean()) {
      Tray.publishMessage("Rightclick the icon for more information.", "Thanks for trying BeST!");
      Prefs.prefs.set("app.displaywelcome", false);
      Prefs.save();
    }
  }
Пример #7
0
 public java.awt.Component getTreeCellRendererComponent(
     javax.swing.JTree tree,
     Object value,
     boolean selected,
     boolean expanded,
     boolean leaf,
     int row,
     boolean hasFocus) {
   openIcon = closedIcon = leafIcon = IconManager.lookupIcon(value);
   java.awt.Component component =
       super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
   if (value instanceof edu.cmu.cs.stage3.alice.core.TextureMap) {
     edu.cmu.cs.stage3.alice.core.TextureMap tm = (edu.cmu.cs.stage3.alice.core.TextureMap) value;
     java.awt.image.BufferedImage image =
         (java.awt.image.BufferedImage) tm.getSceneGraphTextureMap().getImage();
     StringBuffer sb = new StringBuffer();
     sb.append(image.getWidth());
     sb.append('x');
     sb.append(image.getHeight());
     setToolTipText(sb.toString());
   } else if (value instanceof edu.cmu.cs.stage3.alice.core.Model) {
     edu.cmu.cs.stage3.alice.core.Model model = (edu.cmu.cs.stage3.alice.core.Model) value;
     edu.cmu.cs.stage3.alice.core.util.IndexedTriangleArrayCounter itaCounter =
         new edu.cmu.cs.stage3.alice.core.util.IndexedTriangleArrayCounter();
     model.visit(itaCounter, edu.cmu.cs.stage3.util.HowMuch.INSTANCE_AND_PARTS);
     StringBuffer sb = new StringBuffer();
     sb.append("vertices: ");
     sb.append(itaCounter.getVertexCount());
     sb.append("; triangles: ");
     sb.append(itaCounter.getIndexCount() / 3);
     setToolTipText(sb.toString());
   } else {
     setToolTipText(null);
   }
   return component;
 }
Пример #8
0
  private JPopupMenu buildPopupMenu() {
    JPopupMenu popup = new JPopupMenu();

    /* Help -->
     *      About
     *      Instructions
     * -----------------
     * Take Screenshot
     * Save Text
     * Preferences
     * ----
     * Exit
     */

    JMenu helpMenu = new JMenu("Help", true);
    JMenuItem helpAboutMenu = new JMenuItem("About", IconManager.getIcon("help"));
    JMenuItem helpInstructMenu = new JMenuItem("Instructions", IconManager.getIcon("information"));
    helpMenu.add(helpAboutMenu);
    helpMenu.add(helpInstructMenu);
    helpAboutMenu.addActionListener(this);
    helpInstructMenu.addActionListener(this);
    helpAboutMenu.setActionCommand("about");
    helpInstructMenu.setActionCommand("instructions");

    JMenuItem screenshotMenu = new JMenuItem("Take Screenshot", IconManager.getIcon("camera_link"));
    screenshotMenu.addActionListener(this);
    screenshotMenu.setActionCommand("screenshot");

    //        JMenuItem saveTextMenu = new JMenuItem("Save Text to Pastebin",
    // IconManager.getIcon("page_white_link"));
    //        saveTextMenu.addActionListener(this);
    //        saveTextMenu.setActionCommand("text");

    JMenuItem preferencesMenu = new JMenuItem("Preferences", IconManager.getIcon("cog"));
    preferencesMenu.addActionListener(this);
    preferencesMenu.setActionCommand("preferences");

    JMenuItem toolsMenu = new JMenuItem("Tools", IconManager.getIcon("wrench"));
    toolsMenu.addActionListener(this);
    toolsMenu.setActionCommand("tools");

    JMenuItem exitMenu = new JMenuItem("Exit", IconManager.getIcon("cancel"));
    exitMenu.addActionListener(this);
    exitMenu.setActionCommand("exit");

    JMenuItem debugMenu = new JMenuItem("Debug");
    debugMenu.addActionListener(this);
    debugMenu.setActionCommand("debug");

    popup.add(helpMenu);
    popup.addSeparator();
    popup.add(screenshotMenu);
    //        popup.add(saveTextMenu);
    popup.add(toolsMenu);
    popup.add(preferencesMenu);
    popup.addSeparator();
    popup.add(exitMenu);
    popup.addSeparator();
    popup.add(debugMenu);

    return popup;
  }