/** * Creates a new JTextPane for the code. * * @return the text pane */ protected JTextPane newCodePane() { JTextPane result; SyntaxDocument doc; Properties props; try { props = Utils.readProperties(PROPERTIES_FILE); } catch (Exception e) { e.printStackTrace(); props = new Properties(); } result = new JTextPane(); if (props.getProperty("Syntax", "false").equals("true")) { doc = new SyntaxDocument(props); result.setDocument(doc); result.setBackground(doc.getBackgroundColor()); } else { result.setForeground( VisualizeUtils.processColour(props.getProperty("ForegroundColor", "black"), Color.BLACK)); result.setBackground( VisualizeUtils.processColour(props.getProperty("BackgroundColor", "white"), Color.WHITE)); result.setFont( new Font( props.getProperty("FontName", "monospaced"), Font.PLAIN, Integer.parseInt(props.getProperty("FontSize", "12")))); } return result; }
/** * Sets up the document according to the properties. * * @param props the properties to use */ protected void setup(Properties props) { setDelimiters(props.getProperty("Delimiters", ";:{}()[]+-/%<=>!&|^~*")); setQuoteDelimiters(props.getProperty("QuoteDelimiters", "\"\'")); setQuoteEscape(props.getProperty("QuoteEscape", "\\")); setSingleLineCommentStart(props.getProperty("SingleLineCommentStart", "//")); setMultiLineComment(props.getProperty("MultiLineComment", "false").equals("true")); setMultiLineCommentStart(props.getProperty("MultiLineCommentStart", "/*")); setMultiLineCommentEnd(props.getProperty("MultiLineCommentEnd", "*/")); setBlockStart(props.getProperty("BlockStart", "{")); setBlockEnd(props.getProperty("BlockEnd", "}")); setAddMatchingEndBlocks(props.getProperty("AddMatchingBlockEnd", "false").equals("true")); setUseBlanks(props.getProperty("UseBlanks", "false").equals("true")); setCaseSensitive(props.getProperty("CaseSensitive", "true").equals("true")); addKeywords( props.getProperty("Keywords", "").trim().replaceAll(" ", "").split(","), DEFAULT_KEYWORD); setTabs(Integer.parseInt(props.getProperty("Tabs", "2"))); setAttributeColor( DEFAULT_NORMAL, VisualizeUtils.processColour(props.getProperty("ForegroundColor", "black"), Color.BLACK)); setAttributeColor( DEFAULT_COMMENT, VisualizeUtils.processColour(props.getProperty("CommentColor", "gray"), Color.GRAY)); setAttributeColor( DEFAULT_STRING, VisualizeUtils.processColour(props.getProperty("StringColor", "red"), Color.RED)); setAttributeColor( DEFAULT_KEYWORD, VisualizeUtils.processColour(props.getProperty("KeywordColor", "blue"), Color.BLUE)); setBackgroundColor( VisualizeUtils.processColour(props.getProperty("BackgroundColor", "white"), Color.WHITE)); setFontName(props.getProperty("FontName", "monospaced")); setFontSize(Integer.parseInt(props.getProperty("FontSize", "12"))); setIndentationSize(Integer.parseInt(props.getProperty("Indentation", "2"))); }