Example #1
0
  /**
   * Appends a message sent by the system
   *
   * @param text The message to append
   * @param colour The colour of the player, <code>null</code> if none
   */
  private void addSystemText(final String text, final Color colour) {
    StyleContext style = StyleContext.getDefaultStyleContext();
    AttributeSet attrs;

    final int pos0 = getDocument().getLength();
    final int pos1 = pos0 + (text + "\n").length();

    this.setEditable(true);

    attrs =
        style.addAttribute(
            SimpleAttributeSet.EMPTY,
            StyleConstants.Foreground,
            colour == null ? Color.GRAY : colour);
    attrs = style.addAttribute(attrs, StyleConstants.Italic, Boolean.TRUE);

    this.setSelectionStart(pos0);
    this.setSelectionEnd(pos0);
    this.replaceSelection(text + "\n"); // Prints the system's message
    this.setSelectionStart(pos0);
    this.setSelectionEnd(pos1);
    this.setCharacterAttributes(attrs, true);

    this.setSelectionStart(pos1);
    this.setSelectionEnd(pos1);
    this.setEditable(false);
  }
Example #2
0
  {
    StyleContext context = new StyleContext();
    document = new DefaultStyledDocument(context);

    Style style = context.getStyle(StyleContext.DEFAULT_STYLE);
    StyleConstants.setAlignment(style, StyleConstants.ALIGN_LEFT);
  }
  private void initStyles() {
    sc = new StyleContext();
    Style parent = sc.getStyle(StyleContext.DEFAULT_STYLE);

    StyleConstants.setFontFamily(parent, "courier");
    StyleConstants.setFontSize(parent, 13);

    styleElementName = sc.addStyle("elementName", parent);
    StyleConstants.setForeground(styleElementName, new Color(128, 0, 0));

    styleAttribtuteName = sc.addStyle("attributeName", parent);
    StyleConstants.setForeground(styleAttribtuteName, Color.RED);

    styleAttribtuteValue = sc.addStyle("attributeValue", parent);

    styleContent = sc.addStyle("content", parent);
    StyleConstants.setBackground(styleContent, new Color(200, 255, 100));

    styleOperator = sc.addStyle("operator", parent);
    StyleConstants.setForeground(styleOperator, Color.BLUE);
    StyleConstants.setBold(styleOperator, true);

    styleComments = sc.addStyle("comments", parent);
    StyleConstants.setForeground(styleComments, new Color(128, 128, 128)); // Hooker's green

    styleCData = sc.addStyle("cdata", parent);
    StyleConstants.setForeground(styleCData, new Color(30, 30, 0));
    StyleConstants.setBackground(styleCData, new Color(250, 250, 240));

    styleProcessingInstructions = sc.addStyle("processingIntruction", parent);
    styleDOCTYPE = sc.addStyle("doctype", styleComments);
  }
  public void toScreen(String s, Class module, String TYPE) {
    Color c = Color.BLACK;
    if (TYPE != null) {
      if (TYPE.contains("ERROR")) c = Color.RED;
      if (TYPE.contains("WARNING")) c = new Color(255, 106, 0);
      if (TYPE.contains("DEBUG")) c = Color.BLUE;
      if (module.toString().equalsIgnoreCase("Exception")) c = Color.RED;
    }
    StyleContext sc = StyleContext.getDefaultStyleContext();
    javax.swing.text.AttributeSet aset =
        sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
    int len = SCREEN.getDocument().getLength(); // same value as
    SCREEN.setCaretPosition(len); // place caret at the end (with no selection)
    SCREEN.setCharacterAttributes(aset, false);
    SCREEN.replaceSelection(
        "["
            + getData()
            + " - "
            + module.getSimpleName()
            + " - "
            + TYPE
            + "] "
            + s
            + "\n"); // there is no selection, so inserts at caret
    SCREEN.setFont(new Font("Monospaced", Font.PLAIN, 14));

    aggiungiRiga(s, module, TYPE);
  }
Example #5
0
 public static void addStyle(JTextPane pane, String name, Color foreground, Color background) {
   StyledDocument doc = pane.getStyledDocument();
   StyleContext context = StyleContext.getDefaultStyleContext();
   Style defaultStyle = context.getStyle(StyleContext.DEFAULT_STYLE);
   Style style = doc.addStyle(name, defaultStyle);
   StyleConstants.setForeground(style, foreground);
   StyleConstants.setBackground(style, background);
 }
Example #6
0
 public void append(Color c, String s) {
   StyleContext sc = StyleContext.getDefaultStyleContext();
   AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
   int len = getDocument().getLength();
   setCaretPosition(len);
   setCharacterAttributes(aset, false);
   replaceSelection(s);
 }
Example #7
0
 public static void setStyle(JTextPane textPane, int start, int length, String name) {
   StyledDocument doc = textPane.getStyledDocument();
   Style style;
   if (name == null) {
     StyleContext context = StyleContext.getDefaultStyleContext();
     style = context.getStyle(StyleContext.DEFAULT_STYLE);
   } else style = doc.getStyle(name);
   doc.setCharacterAttributes(start, length, style, true);
 }
Example #8
0
  public void appendToPane(String msg, Color c) {
    if (inputText.isEnabled()) {
      StyleContext sc = StyleContext.getDefaultStyleContext();
      AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);

      textArea.setCharacterAttributes(aset, false);
      textArea.replaceSelection(msg);
      textArea.setCaretPosition(textArea.getDocument().getLength());
    }
  }
Example #9
0
 public static void addStyle(
     JTextPane textPane, String name, Color foreground, Color background, boolean bold) {
   StyledDocument doc = textPane.getStyledDocument();
   StyleContext context = StyleContext.getDefaultStyleContext();
   Style def = context.getStyle(StyleContext.DEFAULT_STYLE);
   Style style = doc.addStyle(name, def);
   if (foreground != null) StyleConstants.setForeground(style, foreground);
   if (background != null) StyleConstants.setBackground(style, background);
   StyleConstants.setBold(style, bold);
 }
Example #10
0
  public void append(Color c, String s) { // better implementation--uses
    // StyleContext
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);

    int len = getDocument().getLength(); // same value as
    // getText().length();
    setCaretPosition(len); // place caret at the end (with no selection)
    setCharacterAttributes(aset, false);
    replaceSelection(s); // there is no selection, so inserts at caret
  }
Example #11
0
  public static void appendToPane(JTextPane tp, String msg, Color c) {
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);

    aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console");
    aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED);

    int len = tp.getDocument().getLength();
    tp.setCaretPosition(len);
    tp.setCharacterAttributes(aset, false);
    tp.replaceSelection(msg);
  }
  public ConsoleWindow() {
    if (gui) {
      window = new JFrame("Package Tracking Console");
      window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      window.setSize((int) (screenSize.getWidth() / 4), (int) (screenSize.getHeight() / 1.5));
      window.setLocationRelativeTo(null);
      window.getContentPane().setLayout(new BorderLayout());

      menuBar = new JMenuBar();
      menuBar.add("test", new JLabel("Testing"));
      window.setJMenuBar(menuBar);

      StyleContext sc = new StyleContext();
      document = new DefaultStyledDocument(sc);

      // Styles

      send = sc.addStyle("(Send)", null);
      send.addAttribute(StyleConstants.Foreground, Color.CYAN);

      info = sc.addStyle("(Info)", null);
      info.addAttribute(StyleConstants.Foreground, Color.WHITE);

      warning = sc.addStyle("(Warning)", null);
      warning.addAttribute(StyleConstants.Foreground, Color.YELLOW);

      error = sc.addStyle("(Error)", null);
      error.addAttribute(StyleConstants.Foreground, Color.RED);
      error.addAttribute(StyleConstants.Bold, new Boolean(true));

      textArea = new JTextPane(document);
      textArea.setBackground(new Color(50, 50, 50));
      textArea.setEditable(true);
      textArea.setBorder(null);
      textArea.setForeground(Color.WHITE);

      scrollPane = new JScrollPane(textArea);
      new SmartScroller(scrollPane);

      window.getContentPane().add(scrollPane);

      input = new JTextField();
      input.setBackground(new Color(50, 50, 50));
      input.setForeground(Color.WHITE);
      input.setCaretColor(Color.WHITE);
      input.addActionListener(new test());
      window.getContentPane().add(input, BorderLayout.SOUTH);

      window.setVisible(true);
      info.addAttribute(StyleConstants.Foreground, Color.BLUE);
    }
  }
Example #13
0
 /**
  * Add the provided text with the provided color to the GUI document
  *
  * @param text The text that will be added
  * @param color The color used to show the text
  */
 public void print(String text, Color color) {
   StyleContext sc = StyleContext.getDefaultStyleContext();
   AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, color);
   int len = logPane.getDocument().getLength();
   try {
     logPane.setCaretPosition(len);
     logPane.getDocument().insertString(len, text + "\n", aset);
   } catch (BadLocationException e) {
     LoggerFactory.getLogger(ProcessUIPanel.class).error("Cannot show the log message", e);
   }
   logPane.setCaretPosition(logPane.getDocument().getLength());
 }
Example #14
0
 public ConsolePanel() {
   super(new BorderLayout());
   text.setFont(StyleContext.getDefaultStyleContext().getFont("SansSerif", Font.PLAIN, 10));
   JScrollPane scroller = new JScrollPane(text);
   scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
   add(BorderLayout.CENTER, scroller);
 }
  public void addStylesToDocument(StyledDocument doc) {
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    Style regular = doc.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "Norasi");

    Style s = doc.addStyle("black", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.BLACK);
    StyleConstants.setFontSize(s, 15);

    s = doc.addStyle("orange", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.ORANGE);
    StyleConstants.setFontSize(s, 14);

    s = doc.addStyle("blue", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.BLUE);
    StyleConstants.setFontSize(s, 14);

    s = doc.addStyle("red", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.RED);
    StyleConstants.setFontSize(s, 14);

    s = doc.addStyle("magenta", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.MAGENTA);
    StyleConstants.setFontSize(s, 14);
  }
Example #16
0
  private void utworzStyle() {
    doc = this.poleRozmowy.getStyledDocument();
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    regular = doc.addStyle("regular", def);

    bold = doc.addStyle("bold", regular);
    StyleConstants.setBold(bold, true);
  }
  /** Inits the Styles bold and regular */
  private void initStyles() {
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

    Style regular = this.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");

    Style s = this.addStyle("bold", regular);
    StyleConstants.setBold(s, true);
  }
 private void initializeStyles() {
   errorStyle =
       doc.addStyle(
           "errorStyle",
           StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE));
   errorStyleRed = doc.addStyle("errorStyleRed", errorStyle);
   StyleConstants.setForeground(errorStyleRed, Color.RED);
   errorStyleMono = doc.addStyle("errorStyleMono", errorStyle);
   StyleConstants.setFontFamily(errorStyleMono, "Monospaced");
 }
  /** Adds a Style used to display pictures */
  private void addImageStyle(String uri) throws MalformedURLException {
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

    Style s = this.addStyle("picture", def);
    URL path = new java.net.URL(uri);
    ImageIcon icon = new ImageIcon(path, "ddd");
    if (icon != null) {
      StyleConstants.setIcon(s, icon);
    }
  }
Example #20
0
  protected void addStylesToDocument(final StyledDocument doc) {
    // Initialize some styles.
    final Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

    final Style regular = doc.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");

    Style s = doc.addStyle("entailment", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.blue);

    s = doc.addStyle("color_blue", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.BLUE);

    s = doc.addStyle("color_red", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.RED);

    s = doc.addStyle("color_green", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.GREEN);

    s = doc.addStyle("color_cyan", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.CYAN);

    s = doc.addStyle("color_dark_gray", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.DARK_GRAY);

    s = doc.addStyle("color_pink", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.PINK);

    s = doc.addStyle("color_yellow", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.YELLOW);

    s = doc.addStyle("color_magenta", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.MAGENTA);

    s = doc.addStyle("color_orange", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setForeground(s, Color.ORANGE);

    s = doc.addStyle("unknown", regular);
    StyleConstants.setBold(s, true);
    StyleConstants.setUnderline(s, true);

    s = doc.addStyle("system", regular);
    StyleConstants.setBold(s, true);
  }
Example #21
0
  /**
   * Appends a message sent by a player
   *
   * @param text The message to append
   * @param name The player whom sent the message
   * @param colour The colour of the player
   */
  private void addUserText(final String text, final String name, final Color colour) {
    StyleContext style = StyleContext.getDefaultStyleContext();
    AttributeSet attrs;

    attrs =
        style.addAttribute(
            SimpleAttributeSet.EMPTY,
            StyleConstants.Foreground,
            colour); // Switching to player name style
    attrs = style.addAttribute(attrs, StyleConstants.Bold, Boolean.TRUE);

    final int pos0 = getDocument().getLength();
    final int pos1 = pos0 + (name + ": ").length();
    final int pos2 = pos1 + (text + "\n").length();

    this.setEditable(true);

    this.setSelectionStart(pos0);
    this.setSelectionEnd(pos0);
    this.replaceSelection(name + ": "); // Prints the player's name
    this.setSelectionStart(pos0);
    this.setSelectionEnd(pos1);
    this.setCharacterAttributes(attrs, true);

    attrs =
        style.addAttribute(
            SimpleAttributeSet.EMPTY,
            StyleConstants.Foreground,
            Color.WHITE); // Switing to message style

    this.setSelectionStart(pos1);
    this.setSelectionEnd(pos1);
    this.replaceSelection(text + "\n"); // Prints the player's message
    this.setSelectionStart(pos1);
    this.setSelectionEnd(pos2);
    this.setCharacterAttributes(attrs, true);

    this.setSelectionStart(pos2);
    this.setSelectionEnd(pos2);
    this.setEditable(false);
  }
    private void loadStyles(StyledDocument doc) {
      Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
      StyleConstants.setFontFamily(def, "Courier New");

      // Add normal style
      Style normal = doc.addStyle("normal", def);
      StyleConstants.setForeground(def, Color.LIGHT_GRAY);

      // Add highlighted style from normal
      Style red = doc.addStyle("red", normal);
      StyleConstants.setForeground(red, Color.RED);
    }
 public static void preloadFonts() {
   final BufferedImage image = ImageUtils.createTransparentImage(10, 10);
   final Graphics2D d = image.createGraphics();
   d.setPaint(Color.BLACK);
   final String[] availableFontFamilyNames =
       GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
   for (int i = 0; i < availableFontFamilyNames.length; i++) {
     final String value = availableFontFamilyNames[i];
     d.setFont(StyleContext.getDefaultStyleContext().getFont(value, Font.PLAIN, 12));
     d.drawString(value, 0, 10);
   }
   d.dispose();
 }
Example #24
0
  private void addStylesToHexDump(StyledDocument doc) {
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

    Style base = doc.addStyle("base", def);
    StyleConstants.setFontFamily(base, "Monospaced");

    Style regular = doc.addStyle("regular", base);
    // StyleConstants.setUnderline(regular , true);

    Style s = doc.addStyle("d", regular);
    StyleConstants.setBackground(s, new Color(72, 164, 255));

    s = doc.addStyle("Q", regular);
    StyleConstants.setBackground(s, new Color(255, 255, 128));

    s = doc.addStyle("h", regular);
    StyleConstants.setBackground(s, Color.ORANGE);

    s = doc.addStyle("s", regular);
    StyleConstants.setBackground(s, new Color(156, 220, 156));

    s = doc.addStyle("S", regular);
    StyleConstants.setBackground(s, new Color(156, 220, 156));

    s = doc.addStyle("c", regular);
    StyleConstants.setBackground(s, Color.PINK);

    s = doc.addStyle("f", regular);
    StyleConstants.setBackground(s, Color.LIGHT_GRAY);

    Color bxColor = new Color(255, 234, 213);
    s = doc.addStyle("b", regular);
    StyleConstants.setBackground(s, bxColor);
    s = doc.addStyle("x", regular);
    StyleConstants.setBackground(s, bxColor);

    s = doc.addStyle("op", regular);
    StyleConstants.setBackground(s, Color.YELLOW);

    s = doc.addStyle("selected", regular);
    StyleConstants.setBackground(s, Color.BLUE);

    s = doc.addStyle("chk", regular);
    StyleConstants.setBackground(s, Color.GREEN);
  }
  void finishInit() {
    // Create 3 styles associated with the text panes
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    StyleConstants.setFontFamily(def, "SansSerif");

    Style regular0 = jTextPane.addStyle("regular", def);
    Style regular1 = commentPane.addStyle("regular", def);

    Style s0 = jTextPane.addStyle("old", regular0);
    Style s1 = commentPane.addStyle("old", regular1);
    StyleConstants.setBackground(s0, Color.yellow);
    StyleConstants.setBackground(s1, Color.yellow);

    s0 = jTextPane.addStyle("new", regular0);
    StyleConstants.setBackground(s0, Color.pink);
    s1 = commentPane.addStyle("new", regular1);
    StyleConstants.setBackground(s1, Color.pink);
  }
Example #26
0
  public CustomElementHandler() {
    this.codepane = new CustomCodeTextPane(null);
    this.errorhandler = new ErrorHandler(this.codepane);
    this.helphandler = new HelpHandler(this.codepane, this);
    this.codepane.addMouseMotionListener(this.errorhandler);
    this.codepane.addKeyListener(this.helphandler);
    this.preview = new CustomPreviewHandler();
    this.timer = new Timer(true);
    this.changed = false;
    this.compilation_running = false;
    this.old_text = null;
    this.panel = new CustomElementPanel(this);

    StyledDocument doc = codepane.getStyledDocument();
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    doc.addStyle("default", def);
    Style err = doc.addStyle("error", def);
    StyleConstants.setForeground(err, Color.red);
    StyleConstants.setBold(err, true);
    StyleConstants.setItalic(err, true);
  }
  @SuppressWarnings({"LeakingThisInConstructor", "BooleanConstructorCall"})
  public ConversationTopComponent() {
    initComponents();
    //		setName(Bundle.CTL_ConversationTopComponent());
    //		setToolTipText(Bundle.HINT_ConversationTopComponent());
    m_commandHistory = new Vector<String>();

    StyleContext sc = new StyleContext();
    commanddoc = new DefaultStyledDocument(sc);

    responseStyle = sc.addStyle("Response", null);
    responseStyle.addAttribute(StyleConstants.Foreground, Color.black);
    responseStyle.addAttribute(StyleConstants.FontSize, 16);
    responseStyle.addAttribute(StyleConstants.FontFamily, "serif");
    responseStyle.addAttribute(StyleConstants.Bold, false);

    errorStyle = sc.addStyle("Error", null);
    errorStyle.addAttribute(StyleConstants.Foreground, Color.red);
    errorStyle.addAttribute(StyleConstants.FontSize, 16);
    errorStyle.addAttribute(StyleConstants.FontFamily, "serif");
    errorStyle.addAttribute(StyleConstants.Bold, true);

    commandStyle = sc.addStyle("Command", null);
    commandStyle.addAttribute(StyleConstants.Foreground, Color.blue);
    commandStyle.addAttribute(StyleConstants.FontSize, 16);
    commandStyle.addAttribute(StyleConstants.FontFamily, "serif");
    commandStyle.addAttribute(StyleConstants.Bold, false);

    inCommandStyle = sc.addStyle("InCommand", null);
    inCommandStyle.addAttribute(StyleConstants.Foreground, Color.green);
    inCommandStyle.addAttribute(StyleConstants.FontSize, 16);
    inCommandStyle.addAttribute(StyleConstants.FontFamily, "serif");
    inCommandStyle.addAttribute(StyleConstants.Bold, false);

    warningStyle = sc.addStyle("Warning", null);
    warningStyle.addAttribute(StyleConstants.Foreground, Color.yellow);
    warningStyle.addAttribute(StyleConstants.FontSize, 16);
    warningStyle.addAttribute(StyleConstants.FontFamily, "serif");
    warningStyle.addAttribute(StyleConstants.Bold, true);

    textCommand.setDocument(commanddoc);

    try {
      commanddoc.insertString(0, "Pronto!\n\n", responseStyle);
    } catch (BadLocationException ex) {
      Exceptions.printStackTrace(ex);
    }
  }
Example #28
0
  public void createStyle(
      String style,
      StyledDocument doc,
      int size,
      int bold,
      int italic,
      int underline,
      Color color,
      String fontName) {
    Style sys = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    try {
      doc.removeStyle(style);
    } catch (Exception e) {
    } // ��ɾ������Style,��ʹ������

    Style s = doc.addStyle(style, sys); // ����
    StyleConstants.setFontSize(s, size); // ��С
    StyleConstants.setBold(s, (bold == 1) ? true : false); // ����
    StyleConstants.setItalic(s, (italic == 1) ? true : false); // �
    StyleConstants.setUnderline(s, (underline == 1) ? true : false); // �»���
    StyleConstants.setForeground(s, color); // ��ɫ
    StyleConstants.setFontFamily(s, fontName); // ����
  }
Example #29
0
  public StyleManager(
      SettingsManager settings_manager, DisplayManager display_manager, I18nManager i18n_manager) {
    this.settings_manager = settings_manager;
    this.display_manager = display_manager;
    this.i18n_manager = i18n_manager;

    Vector v = new Vector();

    style_names = new String[0];

    base_style = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    StyleConstants.setFontFamily(
        base_style, settings_manager.getString("/gui/text windows/font face", "Lucida Console"));
    StyleConstants.setFontSize(
        base_style, settings_manager.getInt("/gui/text windows/font size", 14));

    // Read in more styles based on highlight settings.

    int i = 0;
    String i_str;
    String format;
    while (GOD_IS_GOOD) {
      i_str = Integer.toString(i);
      format =
          settings_manager.getString("/gui/text windows/highlighting/" + i_str + "/format", "");
      if (format.equals("")) {
        // No more highlight rules specified.
        break;
      }

      v.add(format);

      i++;
    }

    style_names = (String[]) v.toArray(style_names);
  }
Example #30
0
  private Style createStyle(
      final Color foregroundColor, final Color backgrondColor, final boolean isItalic) {
    final String key =
        String.format(
            "%d-%d-%d %d-%d-%d %s",
            foregroundColor.getRed(),
            foregroundColor.getGreen(),
            foregroundColor.getBlue(),
            backgrondColor.getRed(),
            backgrondColor.getGreen(),
            backgrondColor.getBlue(),
            isItalic);

    Style style = stylesFlyweight.get(key);
    if (style == null) {
      style = StyleContext.getDefaultStyleContext().addStyle(null, null);
      StyleConstants.setForeground(style, foregroundColor);
      StyleConstants.setBackground(style, backgrondColor);
      StyleConstants.setItalic(style, isItalic);
      stylesFlyweight.put(key, style);
    }

    return style;
  }