protected void encodeScript(FacesContext context, ColorPicker colorPicker, String value) throws IOException { String clientId = colorPicker.getClientId(context); WidgetBuilder wb = getWidgetBuilder(context); wb.init("ColorPicker", colorPicker.resolveWidgetVar(), clientId) .attr("mode", colorPicker.getMode()) .attr("color", value, null); encodeClientBehaviors(context, colorPicker); wb.finish(); } }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ColorPicker colorPicker = (ColorPicker) component; Converter converter = colorPicker.getConverter(); String value; if (converter != null) { value = converter.getAsString(context, component, colorPicker.getValue()); } else { value = (String) colorPicker.getValue(); } encodeMarkup(context, colorPicker, value); encodeScript(context, colorPicker, value); }
protected void encodeMarkup(FacesContext context, ColorPicker colorPicker, String value) throws IOException { ResponseWriter writer = context.getResponseWriter(); String clientId = colorPicker.getClientId(context); String inputId = clientId + "_input"; boolean isPopup = colorPicker.getMode().equals("popup"); String styleClass = colorPicker.getStyleClass(); styleClass = styleClass == null ? ColorPicker.STYLE_CLASS : ColorPicker.STYLE_CLASS + " " + styleClass; writer.writeAttribute("id", clientId, "id"); writer.writeAttribute("class", styleClass, "styleClass"); if (colorPicker.getStyle() != null) { writer.writeAttribute("style", colorPicker.getStyle(), "style"); writer.writeAttribute("type", "hidden", null); String onchange = colorPicker.getOnchange(); if (!isValueBlank(onchange)) { writer.writeAttribute("onchange", onchange, null);
@Override public void decode(FacesContext context, UIComponent component) { ColorPicker colorPicker = (ColorPicker) component; if (!shouldDecode(colorPicker)) { return; } String paramName = colorPicker.getClientId(context) + "_input"; Map<String, String> params = context.getExternalContext().getRequestParameterMap(); if (params.containsKey(paramName)) { String submittedValue = params.get(paramName); if (!COLOR_HEX_PATTERN.matcher(submittedValue).matches()) { return; } Converter converter = colorPicker.getConverter(); if (converter != null) { colorPicker.setSubmittedValue( converter.getAsObject(context, component, submittedValue)); } else { colorPicker.setSubmittedValue(submittedValue); } } }
ColorPicker colorPicker = new ColorPicker(); colorPicker.setValue(Color.CHOCOLATE); colorPicker.setOnAction(e -> { createBrushVariations(); }); brushVariations[i] = createBrush(size, colorPicker.getValue());
StackPane root = new StackPane(); final ColorPicker colorssPicker = new ColorPicker(); colorssPicker.setStyle("-fx-background-color: white;"); public void handle(ActionEvent event) root.setBackground(new Background(new BackgroundFill(colorssPicker.getValue(),null,null)));
final ColorPicker colorPicker = new ColorPicker(); colorPicker.setOnAction(new EventHandler() { public void handle(Event t) { Color c = colorPicker.getValue(); System.out.println("New Color's RGB = "+c.getRed()+" "+c.getGreen()+" "+c.getBlue()); } });
fontSizeChoice.setValue(fontSize.get()); ColorPicker colorPicker = new ColorPicker(); colorPicker.setValue(fontFill.get()); fontSize.set(fontSizeChoice.getValue()); italic.set(italicCheckBox.isSelected()); fontFill.set(colorPicker.getValue()); stage.hide(); });
final ColorPicker colorPicker = new ColorPicker(Color.CYAN); colorPicker.setOnAction(e -> { Color color = colorPicker.getValue(); String hex = String.format("#%02x02x02x", (int) (color.getRed() * 255), (int) (color.getGreen() * 255), (int) (color.getBlue() * 255)); Text.setText(hex); ShortcutButton.setBackground( new Background(new BackgroundFill(color, null, null))); }); myLayoutPane.getChildren().add(colorPicker);
if (!wasShownCalled) { wasShownCalled = true; setBarColor(bar, picker.getValue()); picker.valueProperty().addListener(COLOR_LISTENER);
public java.lang.String getOnchange() { return (java.lang.String) getStateHelper().eval(PropertyKeys.onchange, null); } public void setOnchange(java.lang.String _onchange) {
canvas.getGraphicsContext2D().setFill(cp.getValue()); canvas.getGraphicsContext2D().fillOval(20, 20, 20, 20); });
public String resolveWidgetVar() { return ComponentUtils.resolveWidgetVar(getFacesContext(), this); } }
@Override public void decode(FacesContext context, UIComponent component) { ColorPicker colorPicker = (ColorPicker) component; String paramName = colorPicker.getClientId(context) + "_input"; Map<String, String> params = context.getExternalContext().getRequestParameterMap(); if (params.containsKey(paramName)) { String submittedValue = params.get(paramName); if (!COLOR_HEX_PATTERN.matcher(submittedValue).matches()) { return; } Converter converter = colorPicker.getConverter(); if (converter != null) { colorPicker.setSubmittedValue( converter.getAsObject(context, component, submittedValue)); } else { colorPicker.setSubmittedValue(submittedValue); } } }
public java.lang.String getWidgetVar() { return (java.lang.String) getStateHelper().eval(PropertyKeys.widgetVar, null); } public void setWidgetVar(java.lang.String _widgetVar) {
protected void encodeScript(FacesContext context, ColorPicker colorPicker, String value) throws IOException { String clientId = colorPicker.getClientId(context); WidgetBuilder wb = getWidgetBuilder(context); wb.initWithDomReady("ColorPicker", colorPicker.resolveWidgetVar(), clientId) .attr("mode", colorPicker.getMode()) .attr("color", value, null); encodeClientBehaviors(context, colorPicker); wb.finish(); } }
protected void encodeMarkup(FacesContext context, ColorPicker colorPicker, String value) throws IOException { ResponseWriter writer = context.getResponseWriter(); String clientId = colorPicker.getClientId(context); String inputId = clientId + "_input"; boolean isPopup = colorPicker.getMode().equals("popup"); String styleClass = colorPicker.getStyleClass(); styleClass = styleClass == null ? ColorPicker.STYLE_CLASS : ColorPicker.STYLE_CLASS + " " + styleClass; writer.writeAttribute("id", clientId, "id"); writer.writeAttribute("class", styleClass, "styleClass"); if (colorPicker.getStyle() != null) { writer.writeAttribute("style", colorPicker.getStyle(), "style"); writer.writeAttribute("type", "hidden", null); String onchange = colorPicker.getOnchange(); if (!isValueBlank(onchange)) { writer.writeAttribute("onchange", onchange, null);
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ColorPicker colorPicker = (ColorPicker) component; Converter converter = colorPicker.getConverter(); String value; if (converter != null) { value = converter.getAsString(context, component, colorPicker.getValue()); } else { value = (String) colorPicker.getValue(); } encodeMarkup(context, colorPicker, value); encodeScript(context, colorPicker, value); }
public void setMode(java.lang.String _mode) { getStateHelper().put(PropertyKeys.mode, _mode); }
/** * @see org.primefaces.component.colorpicker.ColorPickerRenderer#encodeScript(javax.faces.context.FacesContext, * org.primefaces.component.colorpicker.ColorPicker, java.lang.String) */ @Override protected void encodeScript(FacesContext context, ColorPicker colorPicker, String value) throws IOException { String clientId = colorPicker.getClientId(context); WidgetBuilder wb = getWidgetBuilder(context); wb.init("AjaxColorPicker", colorPicker.resolveWidgetVar(), clientId, "colorpicker").attr("mode", colorPicker.getMode()) .attr("color", value, null); encodeClientBehaviors(context, (ClientBehaviorHolder) colorPicker); wb.finish(); } }