예제 #1
0
 /**
  * Constructs a new {@code RecentRelationsPopupMenu}.
  *
  * @param recentRelations list of recent relations
  * @param keystroke key stroke for the first menu item
  */
 public RecentRelationsPopupMenu(List<Relation> recentRelations, KeyStroke keystroke) {
   boolean first = true;
   for (Relation relation : recentRelations) {
     if (!isRelationListable(relation)) continue;
     JMenuItem menuItem = new RecentRelationsMenuItem(relation);
     if (first) {
       menuItem.setAccelerator(keystroke);
       first = false;
     }
     menuItem.setIcon(
         ImageProvider.getPadded(relation, ImageProvider.ImageSizes.MENU.getImageDimension()));
     add(menuItem);
   }
 }
예제 #2
0
 /**
  * Internal method that stuffs information into the rendering component provided that it's a kind
  * of JLabel.
  *
  * @param def the rendering component
  * @param value the OsmPrimitive to render
  * @param fast whether the icons should be loaded fast since many items are being displayed
  * @return the modified rendering component
  */
 private Component renderer(Component def, OsmPrimitive value, boolean fast) {
   if (value != null && def instanceof JLabel) {
     ((JLabel) def).setText(getComponentText(value));
     final ImageIcon icon =
         fast
             ? ImageProvider.get(value.getType())
             : ImageProvider.getPadded(
                 value,
                 // Height of component no yet known, assume the default 16px.
                 ImageProvider.ImageSizes.SMALLICON.getImageDimension());
     if (icon != null) {
       ((JLabel) def).setIcon(icon);
     } else {
       Main.warn("Null icon for " + value.getDisplayType());
     }
     ((JLabel) def).setToolTipText(getComponentToolTipText(value));
   }
   return def;
 }