private Color createColor(String colorAsHexString) { int[] rgba = ColorHelper.fromHexString(colorAsHexString); return new Color(rgba[0], rgba[1], rgba[2], rgba[3]); }
private void valueToAnything(Color value, Anything args) { String hexColor = ""; if (value != null) { hexColor = ColorHelper.toHexString(value.getRed(), value.getGreen(), value.getBlue(), value.getAlpha()); } args.put(ColorPickerConstants.VALUE_KEY, hexColor); }
static Color createColor(String colorAsHexString) { if (ColorHelper.isColorSpec(colorAsHexString)) { int[] rgba = ColorHelper.fromHexString(colorAsHexString); return new Color(rgba[0], rgba[1], rgba[2], rgba[3]); } return null; }
/** * {@inheritDoc} */ @Override protected void finishComponentConfiguration(IView<RComponent> view, IActionHandler actionHandler, Locale locale) { RComponent viewPeer = view.getPeer(); IViewDescriptor viewDescriptor = view.getDescriptor(); viewPeer.setLabel(viewDescriptor.getI18nName(actionHandler, locale)); String viewDescription = computeViewDescription(viewDescriptor, actionHandler, locale); viewPeer.setToolTip(viewDescription); if (viewDescriptor.getForeground() != null && ColorHelper.isColorSpec(viewDescriptor.getForeground())) { viewPeer.setForeground(viewDescriptor.getForeground()); } if (viewDescriptor.getBackground() != null && ColorHelper.isColorSpec(viewDescriptor.getBackground())) { viewPeer.setBackground(viewDescriptor.getBackground()); } if (viewDescriptor.getFont() != null && FontHelper.isFontSpec(viewDescriptor.getFont())) { viewPeer.setFont(createFont(viewDescriptor.getFont())); } if (viewDescriptor.getIcon() != null) { viewPeer.setIcon(getIconFactory().getIcon(viewDescriptor.getIcon(), getIconFactory().getSmallIconSize())); } else { viewPeer.setIcon(null); } if (viewDescriptor.getStyleName() != null) { viewPeer.setStyleName(viewDescriptor.getStyleName()); } viewPeer.setCollapsible(viewDescriptor.isCollapsible()); viewPeer.setCollapsed(viewDescriptor.isCollapsed()); }
/** * Transforms a color rgba components to their hex string representation. * * @param r * the red component. * @param g * the green component. * @param b * the blue component. * @param a * the alpha (transparency) component. * @return the Hex string representation. */ public static String toHexString(int r, int g, int b, int a) { StringBuffer hexString = new StringBuffer("0x"); hexString.append(formatByteToPaddedHex(a, 2)); hexString.append(formatByteToPaddedHex(r, 2)); hexString.append(formatByteToPaddedHex(g, 2)); hexString.append(formatByteToPaddedHex(b, 2)); return hexString.toString(); }
private void handleSetValue(Anything args) { String hexColor = args.get(ColorPickerConstants.VALUE_KEY, ""); Color newValue = null; if (hexColor.length() > 0) { int[] rgba = ColorHelper.fromHexString(hexColor); newValue = new Color(rgba[0], rgba[1], rgba[2], rgba[3]); } this.value = newValue; }
private void valueToAnything(Color value, Anything args) { String hexColor = ""; if (value != null) { hexColor = ColorHelper.toHexString(value.getRed(), value.getGreen(), value.getBlue(), value.getAlpha()); } args.put(ColorPickerConstants.VALUE_KEY, hexColor); }
private void handleSetValue(Anything args) { String hexColor = args.get(ColorPickerConstants.VALUE_KEY, ""); Color newValue = null; if (hexColor.length() > 0) { int[] rgba = ColorHelper.fromHexString(hexColor); newValue = new Color(rgba[0], rgba[1], rgba[2], rgba[3]); } this.value = newValue; }
/** * {@inheritDoc} */ @Override protected Object getConnecteeValue() { Color value = getConnectedSComponent().getValue(); if (value != null) { return ColorHelper.toHexString(value.getRed(), value.getGreen(), value .getBlue(), value.getAlpha()); } return null; }
/** * {@inheritDoc} */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value != null) { int[] rgba = ColorHelper.fromHexString((String) value); setBackground(new Color(rgba[0], rgba[1], rgba[2], rgba[3])); } else { setBackground(null); } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }
/** * {@inheritDoc} */ @Override protected Object getConnecteeValue() { Color value = getConnectedSComponent().getValue(); if (value != null) { return ColorHelper.toHexString(value.getRed(), value.getGreen(), value .getBlue(), value.getAlpha()); } return null; }
private void handleSetValue(Anything args) { String hexColor = args.get(ColorPickerConstants.VALUE_KEY, ""); Color value = null; if (hexColor.length() > 0) { int[] rgba = ColorHelper.fromHexString(hexColor); value = new Color(rgba[0], rgba[1], rgba[2], rgba[3]); } getBasicObject().setValue(value); }
/** * {@inheritDoc} */ @Override protected Object getConnecteeValue() { Color value = getConnectedJComponent().getValue(); if (value != null) { return ColorHelper.toHexString(value.getRed(), value.getGreen(), value .getBlue(), value.getAlpha()); } return null; }
/** * {@inheritDoc} */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value != null) { int[] rgba = ColorHelper.fromHexString((String) value); setBackground(new Color(rgba[0], rgba[1], rgba[2], rgba[3])); } else { setBackground(null); } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }
/** * {@inheritDoc} */ @Override protected Object protectedGetConnecteeValue() { Color value = getConnectedJComponent().getValue(); if (value != null) { return ColorHelper.toHexString(value.getRed(), value.getGreen(), value.getBlue(), value.getAlpha()); } return null; }
private void handleSetResetValue(Anything args) { String hexColor = args.get(ColorPickerConstants.RESETVALUE_KEY, ""); Color resetValue = null; if (hexColor.length() > 0) { int[] rgba = ColorHelper.fromHexString(hexColor); resetValue = new Color(rgba[0], rgba[1], rgba[2], rgba[3]); } getBasicObject().setResetValue(resetValue); }
private void resetValueToAnything(Anything args) { String hexColor = ""; if (resetValue != null) { hexColor = ColorHelper.toHexString(resetValue.getRed(), resetValue .getGreen(), resetValue.getBlue(), resetValue.getAlpha()); } args.put(ColorPickerConstants.RESETVALUE_KEY, hexColor); }
private void handleResetValue(Anything args) { String hexColor = args.get(ColorPickerConstants.RESETVALUE_KEY, ""); Color resetValue = null; if (hexColor.length() > 0) { int[] rgba = ColorHelper.fromHexString(hexColor); resetValue = new Color(rgba[0], rgba[1], rgba[2], rgba[3]); } getBasicObject().setResetValue(resetValue); }
private void resetValueToAnything(Anything args) { String hexColor = ""; if (resetValue != null) { hexColor = ColorHelper.toHexString(resetValue.getRed(), resetValue .getGreen(), resetValue.getBlue(), resetValue.getAlpha()); } args.put(ColorPickerConstants.RESETVALUE_KEY, hexColor); }
private void handleResetValue(Anything args) { String hexColor = args.get(ColorPickerConstants.RESETVALUE_KEY, ""); Color resetValue = null; if (hexColor.length() > 0) { int[] rgba = ColorHelper.fromHexString(hexColor); resetValue = new Color(rgba[0], rgba[1], rgba[2], rgba[3]); } getBasicObject().setResetValue(resetValue); }