本文整理匯總了Java中javax.swing.text.html.StyleSheet類的典型用法代碼示例。如果您正苦於以下問題:Java StyleSheet類的具體用法?Java StyleSheet怎麽用?Java StyleSheet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
StyleSheet類屬於javax.swing.text.html包,在下文中一共展示了StyleSheet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeStyles
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
/**
* Outputs the styles as a single element. Styles are not stored as
* elements, but part of the document. For the time being styles are
* written out as a comment, inside a style tag.
*/
void writeStyles(StyleSheet sheet) throws IOException {
if (sheet != null) {
Enumeration styles = sheet.getStyleNames();
if (styles != null) {
boolean outputStyle = false;
while (styles.hasMoreElements()) {
String name = (String) styles.nextElement();
// Don't write out the default style.
if (!StyleContext.DEFAULT_STYLE.equals(name)
&& writeStyle(name, sheet.getStyle(name), outputStyle)) {
outputStyle = true;
}
}
if (outputStyle) {
writeStyleEndTag();
}
}
}
}
示例2: postInitComponents
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
private void postInitComponents () {
this.jLabel2.setVisible(false);
this.platformHome.setVisible(false);
final Collection installFolders = platform.getInstallFolderURLs();
if (platform.getInstallFolders().isEmpty() && installFolders.size() > 0) {
this.jLabel2.setVisible(true);
this.platformHome.setVisible(true);
this.platformHome.setForeground(new Color (164,0,0));
this.platformHome.setText (Utilities.toFile(URI.create(((URL)installFolders.iterator().next()).toExternalForm())).getAbsolutePath());
}
HTMLEditorKit htmlkit = new HTMLEditorKit();
StyleSheet css = htmlkit.getStyleSheet();
if (css.getStyleSheets() == null) {
StyleSheet css2 = new StyleSheet();
Font f = jLabel2.getFont();
css2.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
.append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
css2.addStyleSheet(css);
htmlkit.setStyleSheet(css2);
}
jTextPane1.setEditorKit(htmlkit);
jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class,"MSG_BrokenProject"));
}
示例3: createStyleSheet
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
/**
* This method creates and returns a stylesheet that makes the documentation look as it's
* supposed to look.
*
* @return the stylesheet
*/
private StyleSheet createStyleSheet(StyleSheet css) {
css.addRule("* {font-family: Open Sans; font-size: 10px;}");
css.addRule("p {font-size:10px; font-family: Open Sans; margin-top: 0px; padding-top: 0px;}");
css.addRule("ul li {padding-bottom:1ex; font-family: Open Sans; font-size:10px; list-style-type: circle;}");
css.addRule("h2 {font-size:14px; font-family: Open Sans; margin-bottom: 0px; margin-top: 0px;}");
css.addRule("h4 {color: #000000; font-size:10px; font-family: Open Sans; font-weight: bold; margin-bottom: 5px;}");
css.addRule("h5 {color: #3399FF; font-size:11px; font-family: Open Sans;}");
css.addRule("h5 img {margin-right:8px; font-family: Open Sans;}");
css.addRule(".typeIcon {height: 10px; width: 10px;}");
css.addRule("td {vertical-align: top; font-family: Open Sans;}");
css.addRule(".lilIcon {padding: 2px 4px 2px 0px;}");
css.addRule("td {font-size: 10px; font-family: Open Sans;}");
css.addRule(".packageName {color: #777777; font-size:10px; font-family: Open Sans; font-weight: normal;}");
css.addRule(".parameterDetails {color: #777777; font-size:9px; font-family: Open Sans;}");
css.addRule(".tutorialProcessLink {margin-top: 6px; margin-bottom: 5px}");
css.addRule("hr {border: 0;height: 1px;}");
css.addRule("a {color:" + SwingTools.getColorHexValue(Colors.LINKBUTTON_LOCAL) + "}");
return css;
}
示例4: ExtendedHTMLEditorKit
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
public ExtendedHTMLEditorKit() {
styleSheet = new StyleSheet();
try {
InputStream is = HTMLEditorKit.class.getResourceAsStream(DEFAULT_CSS);
Reader r = new BufferedReader(new InputStreamReader(is, "ISO-8859-1"));
styleSheet.loadRules(r, null);
r.close();
} catch (Exception e) {
// LogService.getRoot().log(Level.WARNING, "Cannot install stylesheet: "+e, e);
LogService.getRoot().log(
Level.WARNING,
I18N.getMessage(LogService.getRoot().getResourceBundle(),
"com.rapidminer.gui.tools.ExtendedHTMLEditorKit.installing_stylesheet_error", e), e);
// on error we simply have no styles... the html
// will look mighty wrong but still function.
}
}
示例5: makeMainLabel
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
/**
* Creates the main text representation of this result.
*
* @param text
* @return
*/
private Component makeMainLabel(String text) {
JEditorPane label = new ExtendedHTMLJEditorPane("text/html", text);
StyleSheet css = ((HTMLEditorKit) label.getEditorKit()).getStyleSheet();
css.addRule("body {font-family:Sans;font-size:11pt}");
css.addRule("h3 {margin:0; padding:0}");
css.addRule("h4 {margin-bottom:0; margin-top:1ex; padding:0}");
css.addRule("p {margin-top:0; margin-bottom:1ex; padding:0}");
css.addRule("ul {margin-top:0; margin-bottom:1ex; list-style-image: url("
+ getClass().getResource("/com/rapidminer/resources/icons/modern/help/circle.png") + ")}");
css.addRule("ul li {padding-bottom: 2px}");
css.addRule("li.outPorts {padding-bottom: 0px}");
css.addRule("ul li ul {margin-top:0; margin-bottom:1ex; list-style-image: url("
+ getClass().getResource("/com/rapidminer/resources/icons/modern/help/line.png") + ")");
css.addRule("li ul li {padding-bottom:0}");
label.setEditable(false);
JScrollPane pane = new JScrollPane(label);
pane.setOpaque(false);
pane.setBackground(null);
pane.setBorder(null);
return pane;
}
示例6: buildStyleSheet
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
/**
* This sets all sizes that should be relative to the font size in the HTML
* document. This is to respect the OS font size setting used for example
* on high DPI monitors.
*
* @param styleSheet the <code>StyleSheet</code> to modify
*/
public void buildStyleSheet(StyleSheet styleSheet) {
int baseSize = editorPane.getFont().getSize();
String rule = String.format(
"body { font-size: %dpt; padding: %dpx; }",
Math.round((double) baseSize * 7 / 6),
Math.round((double) baseSize * 5 / 6)
);
styleSheet.addRule(rule);
rule = String.format("h1 { font-size: %dpx; }", baseSize * 2);
styleSheet.addRule(rule);
rule = String.format("h2 { font-size: %dpx; }", Math.round(baseSize * 1.5));
styleSheet.addRule(rule);
rule = String.format("h3 { font-size: %dpx; }", Math.round(baseSize * 1.17));
styleSheet.addRule(rule);
rule = String.format("pre, tt { font-size: %dpt; }", baseSize);
styleSheet.addRule(rule);
rule = String.format("dd { margin-bottom: %dpx; }", Math.round((double) baseSize * 10 / 6));
styleSheet.addRule(rule);
}
示例7: writeStyles
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
/**
* Outputs the styles as a single element. Styles are not stored as
* elements, but part of the document. For the time being styles are written
* out as a comment, inside a style tag.
*/
void writeStyles(StyleSheet sheet) throws IOException {
if (sheet != null) {
Enumeration styles = sheet.getStyleNames();
if (styles != null) {
boolean outputStyle = false;
while (styles.hasMoreElements()) {
String name = (String) styles.nextElement();
// Don't write out the default style.
if (!StyleContext.DEFAULT_STYLE.equals(name)
&& writeStyle(name, sheet.getStyle(name), outputStyle)) {
outputStyle = true;
}
}
if (outputStyle) {
writeStyleEndTag();
}
}
}
}
示例8: createTipBrowser
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
@NotNull
public static JEditorPane createTipBrowser() {
JEditorPane browser = new JEditorPane();
browser.setEditable(false);
browser.setBackground(UIUtil.getTextFieldBackground());
browser.addHyperlinkListener(
new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
BrowserUtil.browse(e.getURL());
}
}
}
);
URL resource = ResourceUtil.getResource(TipUIUtil.class, "/tips/css/", UIUtil.isUnderDarcula() ? "tips_darcula.css" : "tips.css");
final StyleSheet styleSheet = UIUtil.loadStyleSheet(resource);
HTMLEditorKit kit = new HTMLEditorKit() {
@Override
public StyleSheet getStyleSheet() {
return styleSheet != null ? styleSheet : super.getStyleSheet();
}
};
browser.setEditorKit(kit);
return browser;
}
示例9: getHTMLEditorKit
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
public static HTMLEditorKit getHTMLEditorKit(boolean noGapsBetweenParagraphs) {
Font font = getLabelFont();
@NonNls String family = !SystemInfo.isWindows && font != null ? font.getFamily() : "Tahoma";
int size = font != null ? font.getSize() : JBUI.scale(11);
String customCss = String.format("body, div, p { font-family: %s; font-size: %s; }", family, size);
if (noGapsBetweenParagraphs) {
customCss += " p { margin-top: 0; }";
}
final StyleSheet style = new StyleSheet();
style.addStyleSheet(isUnderDarcula() ? (StyleSheet)UIManager.getDefaults().get("StyledEditorKit.JBDefaultStyle") : DEFAULT_HTML_KIT_CSS);
style.addRule(customCss);
return new HTMLEditorKit() {
@Override
public StyleSheet getStyleSheet() {
return style;
}
};
}
示例10: createStyleSheet
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
/**
* This method creates and returns a stylesheet that makes the documentation look as it's
* supposed to look.
*
* @return the stylesheet
*/
private StyleSheet createStyleSheet(StyleSheet css) {
css.addRule("body {font-family: Open Sans; font-size: 10px;}");
css.addRule("p {font-size:10px; font-family: Open Sans; margin-top: 0px; padding-top: 0px;}");
css.addRule("ul li {padding-bottom:1ex; font-family: Open Sans; font-size:10px; list-style-type: circle;}");
css.addRule("h2 {font-size:14px; font-family: Open Sans; margin-bottom: 0px; margin-top: 0px;}");
css.addRule("h4 {color: #000000; font-size:10px; font-family: Open Sans; font-weight: bold; margin-bottom: 5px;}");
css.addRule("h5 {color: #3399FF; font-size:11px; font-family: Open Sans;}");
css.addRule("h5 img {margin-right:8px; font-family: Open Sans;}");
css.addRule(
".parametersHeading {color: #000000; font-size:10px; font-family: Open Sans; font-weight: bold; margin-bottom: 0px;}");
css.addRule(".parametersTable {cellspacing: 0px; border: 0;}");
css.addRule(".typeIcon {height: 10px; width: 10px;}");
css.addRule("td {vertical-align: top; font-family: Open Sans;}");
css.addRule(".lilIcon {padding: 2px 4px 2px 0px;}");
css.addRule("td {font-size: 10px; font-family: Open Sans;}");
css.addRule(".packageName {color: #777777; font-size:10px; font-family: Open Sans; font-weight: normal;}");
css.addRule(".parameterDetails {color: #777777; font-size:9px; font-family: Open Sans;}");
css.addRule(".parameterDetailsCell{margin-bottom: 4px; padding-bottom: 4px;}");
css.addRule(".tutorialProcessLink {margin-top: 6px; margin-bottom: 5px;}");
css.addRule("hr {border: 0;height: 1px;}");
css.addRule("a {color:" + SwingTools.getColorHexValue(Colors.LINKBUTTON_LOCAL) + "}");
css.addRule("table {align:left;}");
css.addRule(".tags {font-size: 9px; color: #777777;}");
return css;
}
示例11: makeMainLabel
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
/**
* Creates the main text representation of this result.
*
* @param text
* @return
*/
private Component makeMainLabel(String text) {
JEditorPane label = new ExtendedHTMLJEditorPane("text/html", text);
StyleSheet css = ((HTMLEditorKit) label.getEditorKit()).getStyleSheet();
css.addRule("body {font-family:Sans;font-size:11pt}");
css.addRule("h3 {margin:0; padding:0}");
css.addRule("h4 {margin-bottom:0; margin-top:1ex; padding:0}");
css.addRule("p {margin-top:0; margin-bottom:1ex; padding:0}");
css.addRule("ul {margin-top:0; margin-bottom:1ex; list-style-image: url("
+ getClass().getResource("/com/rapidminer/resources/icons/modern/help/circle.png") + ")}");
css.addRule("ul li {padding-bottom: 2px}");
css.addRule("li.outPorts {padding-bottom: 0px}");
css.addRule("ul li ul {margin-top:0; margin-bottom:1ex; list-style-image: url("
+ getClass().getResource("/com/rapidminer/resources/icons/modern/help/line.png") + ")");
css.addRule("li ul li {padding-bottom:0}");
label.setEditable(false);
label.setBackground(Colors.WHITE);
JScrollPane pane = new JScrollPane(label);
pane.setBackground(Colors.WHITE);
pane.setBorder(null);
return pane;
}
示例12: ScheduleEditor
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
/**
* Creates new form ScheduleEditor
*/
public ScheduleEditor(Schedule s) {
schedule = s;
initComponents();
if (txtSchedule.getEditorKit() instanceof HTMLEditorKit) {
StyleSheet ss = ((HTMLEditorKit) txtSchedule.getEditorKit()).getStyleSheet();
ss.addRule("a { text-decoration:none; }");
ss.addRule("body { font-family:Tahoma; font-size:12pt; }");
ss.addRule(".column_name { color:#222222; font-weight:bold; }");
ss.addRule(".RangePart { color:#9900bb; }");
ss.addRule(".new { color:#009900; text-decoration:none; font-family:Courier New; }");
ss.addRule(".remove { color:#990000; text-decoration:none; font-family:Courier New; }");
ss.addRule(".rule { padding-left:10px; color:#333333;}");
}
txtSchedule.setText(s.toString());
txtSchedule.addHyperlinkListener(this);
updateFields();
}
示例13: setStyleSheet
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
protected void setStyleSheet() {
if (isRawHtml) return;
MultiMarkdownEditorKit htmlKit = new MultiMarkdownEditorKit();
final StyleSheet style = new MultiMarkdownStyleSheet();
if (!MultiMarkdownGlobalSettings.getInstance().useCustomCss(false)) {
style.importStyleSheet(MultiMarkdownGlobalSettings.getInstance().getCssFileURL(false));
} else {
try {
style.loadRules(new StringReader(MultiMarkdownGlobalSettings.getInstance().getCssText(false)), null);
} catch (IOException e) {
e.printStackTrace();
}
}
htmlKit.setStyleSheet(style);
jEditorPane.setEditorKit(htmlKit);
}
示例14: restoreBackground
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
/** Restore the background.
* @param background The background to be restored.
* @see #saveBackground()
*/
public void restoreBackground(Color background) {
try {
if (background != null) {
// Restore the background color.
String rgb = Integer.toHexString(background.getRGB());
String rule = "body {background: #"
+ rgb.substring(2, rgb.length()) + ";}";
StyleSheet styleSheet = _HTMLEditorKit.getStyleSheet();
styleSheet.addRule(rule);
_HTMLEditorKit.setStyleSheet(styleSheet);
}
} catch (Exception ex) {
log.error("Problem restoring background color. {}", ex);
}
}
示例15: makeStyleSheet
import javax.swing.text.html.StyleSheet; //導入依賴的package包/類
public static StyleSheet makeStyleSheet(String name)
{
try
{
StyleSheet sheet = new StyleSheet();
Reader reader = new InputStreamReader(System.class.getResourceAsStream("/css/" + name + ".css"));
sheet.loadRules(reader, null);
reader.close();
return sheet;
}
catch (Exception ex)
{
ex.printStackTrace();
return null;
}
}