Example #1
0
 static SortedSet<TypeColorEntry> fromPainter(myjava.gui.syntax.Painter painter) {
   Token.Type[] types = Token.Type.values();
   SortedSet<TypeColorEntry> entries = new TreeSet<>();
   for (Token.Type type : types) {
     entries.add(new TypeColorEntry(type, painter.fromType(type)));
   }
   return entries;
 }
Example #2
0
 @Override
 public Component getListCellRendererComponent(
     JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   JLabel label =
       (JLabel)
           (super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus));
   if (value instanceof TypeColorEntry) {
     TypeColorEntry entry = (TypeColorEntry) value;
     Token.Type type = entry.getType();
     Color color = entry.getColor();
     label.setText(Utilities.normalize(type.toString()));
     if ((type == Token.Type.MATCHED_BRACKET) || (type == Token.Type.UNMATCHED_BRACKET)) {
       label.setBackground(color);
       label.setForeground(Color.BLACK);
     } else {
       label.setForeground(color);
     }
   }
   return label;
 }