< prev index next >
modules/javafx.web/src/main/java/javafx/scene/web/HTMLEditorSkin.java
Print this page
*** 1027,1044 ****
strikethroughButton.setSelected(getCommandState(STRIKETHROUGH.getCommand()));
fgColorButton.setDisable(!isCommandEnabled(FOREGROUND_COLOR.getCommand()));
String foregroundColorValue = getCommandValue(FOREGROUND_COLOR.getCommand());
if (foregroundColorValue != null) {
! Color c = Color.web(rgbToHex((String)foregroundColorValue));
fgColorButton.setValue(c);
}
bgColorButton.setDisable(!isCommandEnabled(BACKGROUND_COLOR.getCommand()));
String backgroundColorValue = getCommandValue(BACKGROUND_COLOR.getCommand());
if (backgroundColorValue != null) {
! Color c = Color.web(rgbToHex((String)backgroundColorValue));
bgColorButton.setValue(c);
}
atomicityCount = atomicityCount == 0 ? 0 : --atomicityCount;
}
--- 1027,1044 ----
strikethroughButton.setSelected(getCommandState(STRIKETHROUGH.getCommand()));
fgColorButton.setDisable(!isCommandEnabled(FOREGROUND_COLOR.getCommand()));
String foregroundColorValue = getCommandValue(FOREGROUND_COLOR.getCommand());
if (foregroundColorValue != null) {
! Color c = getColor(foregroundColorValue);
fgColorButton.setValue(c);
}
bgColorButton.setDisable(!isCommandEnabled(BACKGROUND_COLOR.getCommand()));
String backgroundColorValue = getCommandValue(BACKGROUND_COLOR.getCommand());
if (backgroundColorValue != null) {
! Color c = getColor(backgroundColorValue);
bgColorButton.setValue(c);
}
atomicityCount = atomicityCount == 0 ? 0 : --atomicityCount;
}
*** 1117,1149 ****
private String getCommandValue(String command) {
return webPage.queryCommandValue(command);
}
! private static String rgbToHex(String value) {
! if (value.startsWith("rgba")) {
! String[] components = value.substring(value.indexOf('(') + 1, value.lastIndexOf(')')).split(",");
! value = String.format("#%02X%02X%02X%02X",
! Integer.parseInt(components[0].trim()),
! Integer.parseInt(components[1].trim()),
! Integer.parseInt(components[2].trim()),
! Integer.parseInt(components[3].trim()));
! // The default background color for WebView, according to the HTML
! // standard is rgba=#00000000 (black). The canvas background is expected
! // to be white.
! if ("#00000000".equals(value)) {
! return "#FFFFFFFF";
! }
! } else if (value.startsWith("rgb")) {
! String[] components = value.substring(value.indexOf('(') + 1, value.lastIndexOf(')')).split(",");
! value = String.format("#%02X%02X%02X",
! Integer.parseInt(components[0].trim()),
! Integer.parseInt(components[1].trim()),
! Integer.parseInt(components[2].trim()));
}
!
! return value;
}
private void applyTextFormatting() {
if (getCommandState(BULLETS.getCommand()) || getCommandState(NUMBERS.getCommand())) {
return;
--- 1117,1136 ----
private String getCommandValue(String command) {
return webPage.queryCommandValue(command);
}
! private Color getColor(String value) {
! Color color = Color.web(value);
! /* The default background color for WebView, according to the HTML
! * standard is rgba=#00000000 (black). The canvas background is expected
! * to be white.
! */
! if (color.toString().equals("0x00000000")) {
! color = Color.web("#FFFFFFFF");
}
! return color;
}
private void applyTextFormatting() {
if (getCommandState(BULLETS.getCommand()) || getCommandState(NUMBERS.getCommand())) {
return;
< prev index next >