Package javax.swing.text.html

Examples of javax.swing.text.html.StyleSheet


        HTMLEditorKit ektHtml = (HTMLEditorKit) ekt;

        // -------------------------------------
        // 5) assign styleSheet to editorKitHtml

        StyleSheet sstCur = ektHtml.getStyleSheet();

        if (sstCur == null)
        {
            String str = "sstCur == null"; // !!!!!!!!!!
            //GfrHelpBroker._LOGGER_.info(str);
View Full Code Here


        if (_styleSheetURL != null) {
            // If _styleSheetURL is non-null, we set the style sheet
            // once and only once.  If try to do this in a static initializer,
            // then the styles are wrong.
            HTMLDocument doc = (HTMLDocument) pane.getDocument();
            StyleSheet styleSheet = doc.getStyleSheet();
            styleSheet.importStyleSheet(_styleSheetURL);
            new HTMLEditorKit().setStyleSheet(styleSheet);
            _styleSheetURL = null;
        }

        // http://mindprod.com/jgloss/antialiasing.html says that in
View Full Code Here

   */
  public EditorPaneLinkDetector() {

    HTMLEditorKit htmlkit = new HTMLEditorKit();

    StyleSheet styles = htmlkit.getStyleSheet();
    StyleSheet ss = new StyleSheet();

    ss.addStyleSheet(styles);

    ss.addRule("body {font-family:arial;font-size:12pt}");
    ss.addRule("p {font-family:arial;margin:2}");

    HTMLDocument doc = new HTMLDocLinkDetector(ss);

    setEditorKit(htmlkit);

View Full Code Here

    tip.setMargin(new Insets(0, 0, 0, 0));
    final LinkMouseListener linkMouseListener = new LinkMouseListener();
    tip.addMouseListener(linkMouseListener);
    tip.addMouseMotionListener(linkMouseListener);
    final HTMLDocument document = (HTMLDocument) tip.getDocument();
    final StyleSheet styleSheet = document.getStyleSheet();
    styleSheet.removeStyle("p");
    styleSheet.removeStyle("body");
    styleSheet.addRule("p {margin-top:0;}\n");

    final JRestrictedSizeScrollPane scrollPane = new JRestrictedSizeScrollPane(tip);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, maximumWidth / 2));
View Full Code Here

  /**
   * Overriden to return our own slimmed down style sheet.
   */
  public StyleSheet getStyleSheet() {
    if (defaultStyles == null) {
      defaultStyles = new StyleSheet();
      StringReader r = new StringReader(ScaledHTML.styleChanges);
      try {
        defaultStyles.loadRules(r, null);
      }
      catch (Throwable e) {
View Full Code Here

    return defaultStyles;
  }

  @Override
  public Document createDefaultDocument() {
    StyleSheet styles = getStyleSheet();
    StyleSheet ss = new ScaledStyleSheet();
    ss.addStyleSheet(styles);
    HTMLDocument doc = new HTMLDocument(ss);
    doc.setParser(getParser());
    doc.setAsynchronousLoadPriority(4);
    doc.setTokenThreshold(100);
    return doc;
View Full Code Here

  /**
   * Sets the async policy to flush everything in one chunk, and
   * to not display unknown tags.
   */
  Document createDefaultDocument(Font defaultFont, Color foreground) {
    StyleSheet styles = getStyleSheet();
    StyleSheet ss = new ScaledStyleSheet();
    ss.addStyleSheet(styles);
    HTMLDocument doc = new HTMLDocument(ss);
    doc.setPreservesUnknownTags(false);
    doc.getStyleSheet().addRule(displayPropertiesToCSS(defaultFont, foreground));
    doc.setParser(getParser());
    doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
View Full Code Here

    ruleBuilder.append("color: ").append(ColorUtils.colorToString(nodeTextColor)).append(";");
      final Color bgColor = getBackground();
    ruleBuilder.append("background-color: ").append(ColorUtils.colorToString(bgColor)).append(";");
    ruleBuilder.append("}\n");
    final HTMLDocument document = (HTMLDocument) textfield.getDocument();
    final StyleSheet styleSheet = document.getStyleSheet();
    styleSheet.addRule(ruleBuilder.toString());
    textfield.setText(text);
    final MapView mapView = (MapView) viewController.getMapViewComponent();
    if(! mapView.isValid())
      mapView.validate();
    final NodeStyleController nsc = NodeStyleController.getController(modeController);
View Full Code Here

    }
    southPanel.revalidate();
  }

  void setDefaultFont() {
      final StyleSheet styleSheet = noteViewerComponent.getDocument().getStyleSheet();
      styleSheet.removeStyle("body");
      styleSheet.removeStyle("p");
      // set default font for notes:
      final NodeStyleController style = Controller.getCurrentModeController().getExtension(
          NodeStyleController.class);
      MapModel map = Controller.getCurrentModeController().getController().getMap();
      if(map != null){
          final Font defaultFont;
          defaultFont = style.getDefaultFont(map, MapStyleModel.NOTE_STYLE);
          String rule = "body {";
          rule += "font-family: " + defaultFont.getFamily() + ";";
          rule += "font-size: " + defaultFont.getSize() + "pt;";
            if (defaultFont.isItalic()) {
                rule += "font-style: italic; ";
            }
            if (defaultFont.isBold()) {
                rule += "font-weight: bold; ";
            }
          rule += "}\n";
          styleSheet.addRule(rule);
      }
      if (ResourceController.getResourceController().getBooleanProperty(
          MNoteController.RESOURCES_USE_MARGIN_TOP_ZERO_FOR_NOTES)) {
      /* this is used for paragraph spacing. I put it here, too, as
       * the tooltip display uses the same spacing. But it is to be discussed.
       * fc, 23.3.2009.
       */
      String rule = "p {";
      rule += "margin-top:0;";
      rule += "}\n";
      styleSheet.addRule(rule);
    }
  }
View Full Code Here

      final JEditorPane editorPane = htmlEditorPanel.getEditorPane();
      if(textColor != null){
        editorPane.setForeground(textColor);
        editorPane.setCaretColor(textColor);
      }
      final StyleSheet styleSheet = document.getStyleSheet();
      styleSheet.removeStyle("p");
      styleSheet.removeStyle("body");
      styleSheet.addRule(ruleBuilder.toString());
      final URL url = node.getMap().getURL();
      if (url != null) {
        document.setBase(url);
      }
      else {
View Full Code Here

TOP

Related Classes of javax.swing.text.html.StyleSheet

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.