/* PseudoCode Interpreted Language (PCIL): Part of the algoviz@vt collection of algorithm visualizations. Copyright (C) 2008 Brandon Malone, Frank Hadlock This file is part of the PseudoCode Interpreted Language. PseudoCode Interpreted Language is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. PseudoCode Interpreted Language is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with PseudoCode Interpreted Language. If not, see . */ /* * HTMLRenderer.java * * Created on March 15, 2008, 1:02 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package dynamicmvc; import java.awt.Component; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; /** * * @author Brandon */ /* ** Use HTML to format the text */ class HTMLRenderer extends DefaultListCellRenderer { private static final String START = ""; private static final String END = "
"; private static StringBuilder tabs = new StringBuilder(); public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus); String item = (String)value; item = item.replace("<", "<"); // change each of the \t's at the beginning to 20 px indentions tabs.setLength(0); while(item.startsWith("\t")) { tabs.append(" "); item = item.substring(1); } tabs.append(""); item = tabs.toString().concat(item).concat(""); String text = START + item + END; setText(text); return this; } }