Package javax.swing.text

Examples of javax.swing.text.Style


  public void saveColorPreferences(File file) throws IOException {
    Properties prefs1 = new Properties();
    Iterator<String> it = this.styleMap.keySet().iterator();
    String type;
    Style style;
    Color fg, bg;
    while (it.hasNext()) {
      type = it.next();
      style = this.styleMap.get(type);
      fg = StyleConstants.getForeground(style);
View Full Code Here


    FileOutputStream out = new FileOutputStream(file);
    prefs1.store(out, "Color preferences for annotation viewer.");
  }

  public void loadColorPreferences(File file) throws IOException {
    Style parent = this.styleMap.get(CAS.TYPE_NAME_ANNOTATION);
    StyleContext sc = StyleContext.getDefaultStyleContext();
    Properties prefs1 = new Properties();
    FileInputStream in = new FileInputStream(file);
    prefs1.load(in);
    String typeName, value;
    Style style;
    Color color;
    int pos;
    Iterator<?> it = prefs1.keySet().iterator();
    while (it.hasNext()) {
      typeName = (String) it.next();
View Full Code Here

  }

  private JPanel createCustomizationPanel(String typeName) {
    this.currentTypeName = typeName;
    String defaultAnnotStyleName = CAS.TYPE_NAME_ANNOTATION;
    Style defaultAnnotStyle = this.styleMap.get(defaultAnnotStyleName);
    GridLayout layout = new GridLayout(0, 1);
    JPanel topPanel = new JPanel(layout);
    this.textPane = new JTextPane();
    Style style = this.styleMap.get(typeName);
    if (style == null) {
      style = defaultAnnotStyle;
    }
    Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    this.textPane.addStyle(defaultStyleName, defaultStyle);
    setCurrentStyle(style);
    this.fgColor = StyleConstants.getForeground(this.currentStyle);
    this.bgColor = StyleConstants.getBackground(this.currentStyle);
    this.fgIcon = new ColorIcon(this.fgColor);
View Full Code Here

    return topPanel;
  }

  private void setCustomizationPanel(String typeName) {
    this.currentTypeName = typeName;
    Style defaultAnnotStyle = this.styleMap.get(CAS.TYPE_NAME_ANNOTATION);
    Style style = this.styleMap.get(typeName);
    if (style == null) {
      style = defaultAnnotStyle;
    }
    // Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(
    // StyleContext.DEFAULT_STYLE);
View Full Code Here

    buttonPanel.add(this.cancelButton);
    enableButtons(false);
  }

  private void setTextPane() {
    Style defaultStyle = this.textPane.getStyle(defaultStyleName);
    // Style style = textPane.getStyle(typeName);
    // if (style == null || defaultStyle == null) {
    // System.out.println("Style is null.");
    // }
    Document doc = this.textPane.getDocument();
View Full Code Here

  }

  private class AcceptButtonHandler implements ActionListener {

    public void actionPerformed(ActionEvent event) {
      Style style = AnnotationDisplayCustomizationFrame.this.styleMap
          .get(AnnotationDisplayCustomizationFrame.this.currentTypeName);
      if (style == null) {
        style = AnnotationDisplayCustomizationFrame.this.textPane.addStyle(
            AnnotationDisplayCustomizationFrame.this.currentTypeName,
            AnnotationDisplayCustomizationFrame.this.styleMap.get(CAS.TYPE_NAME_ANNOTATION));
View Full Code Here

  }

  private class CancelButtonHandler implements ActionListener {

    public void actionPerformed(ActionEvent event) {
      Style style = AnnotationDisplayCustomizationFrame.this.styleMap
          .get(AnnotationDisplayCustomizationFrame.this.currentTypeName);
      if (style == null) {
        style = AnnotationDisplayCustomizationFrame.this.styleMap.get(CAS.TYPE_NAME_ANNOTATION);
      }
      // assert(style != null);
View Full Code Here

            welcomeTextView.setFocusable(false);
            welcomeTextView.setEditable(false);

            // Set font
            HTMLDocument doc = (HTMLDocument)welcomeTextView.getDocument();
            final Style style = doc.addStyle("normal", null);
            doc.setCharacterAttributes(0, doc.getLength(), style, false);

            welcomeText = welcomeTextView;
        } catch (IOException e)
        {
View Full Code Here

     * @param stylefile the name of the text file
     * @throws Exception an Exception is thrown if the stylefile can't be read
     */
    public void init(String stylefile)
            throws Exception {
        Style default_style = m_doc.addStyle(StyleContext.DEFAULT_STYLE, m_doc.getLogicalStyle(0));
        Style parent_style = default_style;
        TextFile file = new TextFile(stylefile);

        file.openForRead(file_id);

        TextToken token = file.nextToken();

        for (; token != null; token = file.nextToken()) {
            parent_style = default_style;
            String style_name = token.getString();

            if (token.isIdentifier()) {

                token = file.nextToken();

                if (token.isIdentifier("extends")) {
                    token = file.nextToken();

                    Style ps = m_doc.getStyle(token.getString());

                    if (ps != null) {
                        parent_style = ps;
                    }

                    token = file.nextToken();
                }

                Style new_style = m_doc.addStyle(style_name, parent_style);

                error("new style " + style_name);

                if (!token.isChar('{')) {
                    throw new Exception("Can't read style on line " + file.getActLine());
View Full Code Here

    public Color stringToColor(final String colorNameOrHex) {
        return CSS.ColorProperty.stringToColor(colorNameOrHex);
    }

    public AttributeSet translateHTMLToCSS(final AttributeSet htmlAttrSet) {
        final Style result = addStyle(null, null);
//        if (((Element)htmlAttrSet).isLeaf()) {
//            return result;
//        }

        final Enumeration keys = htmlAttrSet.getAttributeNames();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = htmlAttrSet.getAttribute(key);
            if (key instanceof CSS.Attribute) {
                result.addAttribute(key, value);
            } else {
                Object cssKey = HTML_ATTRIBUTE_TO_CSS.get(key);
                if (cssKey != null
                    && ((Attribute)cssKey).getConverter() != null) {

                    if ((key == HTML.Attribute.HEIGHT
                         || key == HTML.Attribute.WIDTH)
                        && value instanceof String
                        && !((String)value).endsWith("%")) {

                        value = ((Attribute)cssKey).getConverter()
                                .toCSS((String)value + /*"px"*/ "pt");
                    } else if (key == HTML.Attribute.BACKGROUND) {
                        value = ((Attribute)cssKey).getConverter()
                                .toCSS("url(" + value + ")");
                    } else {
                        value = ((Attribute)cssKey).getConverter().toCSS(value);
                    }

                    if (value != null) {
                        result.addAttribute(cssKey, value);
                    }
                }
            }
        }
        return result;
View Full Code Here

TOP

Related Classes of javax.swing.text.Style

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.