本文整理汇总了Java中org.eclipse.jface.resource.StringConverter.asRGB方法的典型用法代码示例。如果您正苦于以下问题:Java StringConverter.asRGB方法的具体用法?Java StringConverter.asRGB怎么用?Java StringConverter.asRGB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.resource.StringConverter
的用法示例。
在下文中一共展示了StringConverter.asRGB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
public List<SyntaxStyle> get() {
ArrayList<SyntaxStyle> result = new ArrayList<SyntaxStyle>();
setDefaults(store);
for (SyntaxStyle s : defaultStyles) {
boolean enable = store.getBoolean(getStyleKey(StyleAspect.enable, s.displayName));
RGB color = StringConverter.asRGB(store.getString(getStyleKey(StyleAspect.color, s.displayName)));
boolean bold = store.getBoolean(getStyleKey(StyleAspect.bold, s.displayName));
;
boolean italic = store.getBoolean(getStyleKey(StyleAspect.italic, s.displayName));
;
boolean strikethrough = store.getBoolean(getStyleKey(StyleAspect.strikethrough, s.displayName));
;
boolean underline = store.getBoolean(getStyleKey(StyleAspect.underline, s.displayName));
;
result.add(new SyntaxStyle(s.displayName, s.type, enable, color, bold, italic, strikethrough, underline));
}
return result;
}
示例2: adaptToColorChange
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
private void adaptToColorChange(Token token, PropertyChangeEvent event) {
RGB rgb = null;
Object value = event.getNewValue();
if (value instanceof RGB) {
rgb = (RGB) value;
} else if (value instanceof String) {
rgb = StringConverter.asRGB((String) value);
}
if (rgb != null) {
String property = event.getProperty();
Color color = colorMgr.getColor(property);
if (!rgb.equals(color.getRGB())) {
colorMgr.setValue(property, rgb);
color = colorMgr.getColor(property);
}
Object data = token.getData();
if (data instanceof TextAttribute) {
TextAttribute oldAttr = (TextAttribute) data;
token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
}
}
}
示例3: colorFromString
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
public static Color colorFromString(String rgbString) {
if (rgbString != null && rgbString.trim().length() > 0) {
Color col = JFaceResources.getColorRegistry().get(rgbString);
try {
if (col == null) {
RGB rgb = StringConverter.asRGB(rgbString);
JFaceResources.getColorRegistry().put(rgbString, rgb);
col = JFaceResources.getColorRegistry().get(rgbString);
}
}
catch (DataFormatException e) {
log.error("Corrupt color value: " + rgbString, e);
}
return col;
}
return null;
}
示例4: getColorForKeyWithoutDefault
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
protected Color getColorForKeyWithoutDefault(String key) {
Color result = null;
try {
if (!Raptor.getInstance().getColorRegistry().hasValueFor(key)) {
// We don't want the default color if not found we want to
// return null, so use
// StringConverter instead of PreferenceConverter.
String value = getString(key);
if (StringUtils.isNotBlank(value)) {
RGB rgb = StringConverter.asRGB(value, null);
if (rgb != null) {
Raptor.getInstance().getColorRegistry().put(key, rgb);
} else {
return null;
}
} else {
return null;
}
}
result = Raptor.getInstance().getColorRegistry().get(key);
} catch (Throwable t) {
result = null;
}
return result;
}
示例5: getColor
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
private Color getColor(final String configurationKey, final String defaultColorKey) {
String colorKey = configuration.getString(configurationKey, defaultColorKey);
RGB rgbColorData;
try {
rgbColorData = StringConverter.asRGB(colorKey);
}
catch (final RuntimeException e) {
logger.log(Level.FINER, e.toString(), e);
logger.log(Level.INFO, Messages.get("err.invalid.color"), colorKey);
colorKey = defaultColorKey;
rgbColorData = StringConverter.asRGB(colorKey);
}
final ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
if (!colorRegistry.hasValueFor(colorKey)) {
colorRegistry.put(colorKey, rgbColorData);
}
return colorRegistry.get(colorKey);
}
示例6: parseRGB
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
/**
* Converts a String to RGB, could be of several formats
* * @see {@link StringUtils}
*/
public static RGB parseRGB(String valueString) {
try {
if (valueString != null && valueString.startsWith("#")) {
valueString = valueString.substring(1);
}
Integer hexcode = Integer.parseInt(valueString, 16);
if (hexcode != null) {
return new RGB((hexcode/256/256)%256, (hexcode/256)%256, hexcode%256);
}
} catch (NumberFormatException e) {
try {
return StringConverter.asRGB(valueString);
} catch (Exception x) {
// ignore it
}
}
return null;
}
示例7: adaptToTextForegroundChange
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
private void adaptToTextForegroundChange(Highlighting highlighting, PropertyChangeEvent event) {
RGB rgb= null;
Object value= event.getNewValue();
if (value instanceof RGB)
rgb= (RGB) value;
else if (value instanceof String)
rgb= StringConverter.asRGB((String) value);
if (rgb != null) {
String property= event.getProperty();
Color color= fColorManager.getColor(property);
if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) {
IColorManagerExtension ext= (IColorManagerExtension) fColorManager;
ext.unbindColor(property);
ext.bindColor(property, rgb);
color= fColorManager.getColor(property);
}
TextAttribute oldAttr= highlighting.getTextAttribute();
highlighting.setTextAttribute(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
}
}
示例8: returnPropertyValue
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
/**
* @param feature
* @param result
* @return value
*/
protected Object returnPropertyValue(EStructuralFeature feature, Object result) {
if (result instanceof Integer) {
result = ((Integer) result).toString();
} else if (result instanceof Double) {
result = ((Double) result).toString();
} else if (result instanceof Boolean) {
// result = ((Boolean) result).booleanValue() ? new Integer(1) : new
// Integer(0);
// result = result;
} else if (feature.getName().toLowerCase().indexOf("color") >= 0) { //$NON-NLS-1$
if (result == null || ((String) result).length() == 0)
result = new RGB(0, 0, 0);
else
result = StringConverter.asRGB((String) result);
}
return result;
}
示例9: load
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
public SQLEditorSyntaxModel load() {
color = StringConverter.asRGB(prefStore.getString(
type.getPrefName() + PREF_COLOR));
bold = prefStore.getBoolean(type.getPrefName() + PREF_BOLD);
italic = prefStore.getBoolean(type.getPrefName() + PREF_ITALIC);
strikethrough = prefStore.getBoolean(type.getPrefName() + PREF_STRIKETHROUGH);
underline = prefStore.getBoolean(type.getPrefName() + PREF_UNDERLINE);
return this;
}
示例10: loadDefault
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
public SQLEditorSyntaxModel loadDefault() {
color = StringConverter.asRGB(prefStore.getDefaultString(
type.getPrefName()+ PREF_COLOR));
bold = prefStore.getDefaultBoolean(type.getPrefName() + PREF_BOLD);
italic = prefStore.getDefaultBoolean(type.getPrefName() + PREF_ITALIC);
strikethrough = prefStore.getDefaultBoolean(type.getPrefName() + PREF_STRIKETHROUGH);
underline = prefStore.getDefaultBoolean(type.getPrefName() + PREF_UNDERLINE);
return this;
}
示例11: getFillColor
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
/**
* getFillColor
*
* @return RGB
*/
protected RGB getFillColor() {
RGB nodeColor = PreferenceUtil.INSTANCE.getNodeLineColor();
AbstractConnection viewModel = (AbstractConnection) getModel();
if (viewModel != null) {
if (viewModel.getFillColor() != null) {
nodeColor = StringConverter.asRGB(viewModel.getFillColor());
}
}
return nodeColor;
}
示例12: getFontColor
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
/**
* getFontColor
*
* @return RGB
*/
protected RGB getFontColor() {
RGB fontColor = PreferenceUtil.INSTANCE.getNodeFontColor();
AbstractView viewModel = (AbstractView) ((AbstractView) getModel()).getParent();
if (viewModel != null) {
if (viewModel.getFontColor() != null) {
fontColor = StringConverter.asRGB(viewModel.getFontColor());
}
}
return fontColor;
}
示例13: getFontColor
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
/**
* getFontColor
*
* @return RGB
*/
protected RGB getFontColor() {
RGB fontColor = PreferenceUtil.INSTANCE.getNodeFontColor();
AbstractView abstractView = (AbstractView) ((AbstractView) getModel()).getParent();
if (abstractView != null) {
if (abstractView.getFontColor() != null) {
fontColor = StringConverter.asRGB(abstractView.getFontColor());
}
}
return fontColor;
}
示例14: getFillColor
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
/**
* getFillColor
*
* @return RGB
*/
protected RGB getFillColor() {
RGB nodeColor = PreferenceUtil.INSTANCE.getNodeFillColor();
NotationNode viewModel = (NotationNode) getModel();
if (viewModel != null) {
if (viewModel.getFillColor() != null) {
nodeColor = StringConverter.asRGB(viewModel.getFillColor());
} else {
if (NodeType.INITIAL_NODE.equals(viewModel.getNodeType())
|| NodeType.ACTIVITY_FINAL_NODE.equals(viewModel.getNodeType())) {
RGB blackColor = UiCorePlugin.getDefault().getColor("Black").getRGB();
nodeColor = blackColor;
}
if (viewModel.getNodeType().equals(NodeType.ACTOR)) {
nodeColor = ColorConstants.lightGray.getRGB();
}
if (viewModel.getNodeType().equals(NodeType.JOIN_NODE)) {
nodeColor = new RGB(240, 240, 240);
}
if (viewModel.getNodeType().equals(NodeType.FORK_NODE)) {
nodeColor = new RGB(240, 240, 240);
}
}
}
return nodeColor;
}
示例15: getFontColor
import org.eclipse.jface.resource.StringConverter; //导入方法依赖的package包/类
/**
* getFontColor
*
* @return RGB
*/
protected RGB getFontColor() {
RGB fontColor = PreferenceUtil.INSTANCE.getNodeFontColor();
NotationNode viewModel = (NotationNode) getModel();
if (viewModel != null) {
if (viewModel.getFontColor() != null) {
fontColor = StringConverter.asRGB(viewModel.getFontColor());
}
}
return fontColor;
}