public static String getString( IGraphicalPart part, IStyleSelector ss, String key, String defaultValue) { if (part != null && ss != null) { String value = ss.getStyleValue(part, key); if (value != null) return value; } return defaultValue; }
public static RGB getRGB( IGraphicalPart part, IStyleSelector ss, String key, String decorationId) { if (part != null && ss != null) { String value = ss.getStyleValue(part, key); return convertRGB(key, value); } return null; }
public static String getIndexedBranchLineColor(IBranchPart branch) { IBranchPart parent = branch.getParentBranch(); if (parent != null) { int index = parent.getSubBranches().indexOf(branch); if (index >= 0) { IStyleSelector parentSS = StyleUtils.getStyleSelector(parent); String value = parentSS.getUserValue(parent, Styles.MultiLineColors); ISheetPart sheet = null; if (value == null) { // compatible with former versions: IViewer viewer = parent.getSite().getViewer(); if (viewer != null) { sheet = (ISheetPart) viewer.getAdapter(ISheetPart.class); if (sheet != null) { value = StyleUtils.getStyleSelector(sheet).getUserValue(sheet, Styles.MultiLineColors); } } } if (value == null) { value = parentSS.getStyleValue(parent, Styles.MultiLineColors); } // if (value == null && sheet != null) { // value = StyleUtils.getStyleSelector(sheet).getStyleValue( // sheet, Styles.MultiLineColors); // } if (value != null) { if (!Styles.NONE.equals(value)) { value = value.trim(); // split by whitespaces String[] colors = value.split("[\\s]+"); // $NON-NLS-1$ if (colors.length > 0) { index %= colors.length; String color = colors[index].trim(); return color; } } } return null; } } return null; }
private static int getAlignValue(IGraphicalPart part, IStyleSelector ss, String key) { // TODO Auto-generated method stub if (part != null && ss != null) { String value = ss.getStyleValue(part, key); if (Styles.ALIGN_CENTER.equals(value)) return PositionConstants.CENTER; else if (Styles.ALIGN_RIGHT.equals(value)) return PositionConstants.RIGHT; else return PositionConstants.LEFT; } return PositionConstants.LEFT; }
public static Font getFont(IGraphicalPart part, IStyleSelector ss, String key) { if (part != null && ss != null) { String value = ss.getStyleValue(part, key); if (value != null) { Font f = FontUtils.getFont(value); if (f != null) return f; } } return null; }
public static boolean isBranchLineTapered(IBranchPart branch, IStyleSelector ss) { if (branch != null && ss != null && branch.isCentral()) { String value = ss.getUserValue(branch, Styles.LineTapered); if (value == null) { // compatible with former versions: IViewer viewer = branch.getSite().getViewer(); if (viewer != null) { ISheetPart sheet = (ISheetPart) viewer.getAdapter(ISheetPart.class); if (sheet != null) { value = getStyleSelector(sheet).getUserValue(sheet, Styles.LineTapered); } } } if (value == null) { value = ss.getStyleValue(branch, Styles.LineTapered); } return value != null && value.contains(Styles.TAPERED); } return false; }
public static int getLineStyle( IGraphicalPart part, IStyleSelector ss, String key, String decorationId, int defaultValue) { if (part != null && ss != null) { String value = ss.getStyleValue(part, key, getDecorationDefaultValueProvider(decorationId, key)); if (value != null) { return toSWTLineStyle(value, defaultValue); } } return defaultValue; }
public static Color getColor( IGraphicalPart part, IStyleSelector ss, String key, String decorationId, String defaultColor) { if (part != null && ss != null) { String value = ss.getStyleValue(part, key, getDecorationDefaultValueProvider(decorationId, key)); if (value != null) return convertColor(key, value); } return convertColor(key, defaultColor); }
public static double getDouble( IGraphicalPart part, IStyleSelector ss, String key, double defaultValue) { if (part != null && ss != null) { String value = ss.getStyleValue(part, key); if (value != null) { value = trimNumber(value); try { return Double.parseDouble(value); } catch (Exception e) { } } } return defaultValue; }
public static int getInteger( IGraphicalPart part, IStyleSelector ss, String key, String decorationId, int defaultValue) { if (part != null && ss != null) { String value = ss.getStyleValue(part, key, getDecorationDefaultValueProvider(decorationId, key)); if (value != null) { value = trimNumber(value); try { return Integer.parseInt(value); } catch (Exception e) { } } } return defaultValue; }