/** * Ajoute les commandes <code> * \\definecolor{colourName}{rgb}{<var>r</var>,<var>g</var>,<var>b</var>} * </code> au tampon <code>buf</code> passé en argument. * * @since jPicEdt 1.6 */ public static void addUserDefinedColourDefinitions( StringBuffer buf, ParameterString p, TikzFormatter factory) { float[] colourComponents = new float[3]; for (ParameterString.UserDefinedColour c : p.getUserDefinedColourList()) { buf.append("\\definecolor{"); buf.append(c.name); buf.append("}{rgb}{"); colourComponents = c.colour.getRGBColorComponents(colourComponents); buf.append(PEToolKit.doubleToString(colourComponents[0])); buf.append(","); buf.append(PEToolKit.doubleToString(colourComponents[1])); buf.append(","); buf.append(PEToolKit.doubleToString(colourComponents[2])); buf.append("}"); buf.append(factory.getLineSeparator()); } }
/** * Returns a "\\psset{…}" buffer containing default parameters (useful if these differ from * PsTricks's ones) This is very similar to <code>createParameterString()</code> except that a * default attribute set is used, and dimensional parameters are taken into account, for which * jPicEdt's default values slightly differ from PsTricks's default (mostly due to the use of mm * instead of postscript points as the basic unit). */ public static StringBuffer createDefaultParameterString( PicAttributeSet defaultAttributes, TikzFormatter factory) { ColorFormatter.ColorEncoding predefinedColorSet = factory.getCustomProperties().getFormatterPredefinedColorSet(); StringBuffer paramBuf = new StringBuffer(100); paramBuf.append("\\psset{"); paramBuf.append("linewidth="); paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(LINE_WIDTH))); paramBuf.append(",dotsep="); paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(DOT_SEP))); paramBuf.append(",hatchwidth="); paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(HATCH_WIDTH))); paramBuf.append(",hatchsep="); paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(HATCH_SEP))); paramBuf.append(",shadowsize="); paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(SHADOW_SIZE))); paramBuf.append(",dimen=middle"); // same as java // [SR:pending] not used yet // paramBuf.append(",doublesep="); // paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(DOUBLE_SEP))); paramBuf.append("}"); paramBuf.append(factory.getLineSeparator()); paramBuf.append("\\psset{"); paramBuf.append("dotsize="); paramBuf.append( PEToolKit.doubleToString(defaultAttributes.getAttribute(POLYDOTS_SIZE_MINIMUM_MM))); paramBuf.append(' '); paramBuf.append( PEToolKit.doubleToString(defaultAttributes.getAttribute(POLYDOTS_SIZE_LINEWIDTH_SCALE))); paramBuf.append(",dotscale="); paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(POLYDOTS_SCALE_H))); paramBuf.append(' '); paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(POLYDOTS_SCALE_V))); // --- fill color = black (PsTricks doesn't seem to fill in black by default) paramBuf.append(",fillcolor="); paramBuf.append( ColorFormatter.format(defaultAttributes.getAttribute(FILL_COLOR), predefinedColorSet)); paramBuf.append("}"); paramBuf.append(factory.getLineSeparator()); // arrow params paramBuf.append("\\psset{"); paramBuf.append("arrowsize="); paramBuf.append( PEToolKit.doubleToString(defaultAttributes.getAttribute(ARROW_WIDTH_MINIMUM_MM))); paramBuf.append(' '); paramBuf.append( PEToolKit.doubleToString(defaultAttributes.getAttribute(ARROW_WIDTH_LINEWIDTH_SCALE))); paramBuf.append(",arrowlength="); paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(ARROW_LENGTH_SCALE))); paramBuf.append(",arrowinset="); paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(ARROW_INSET_SCALE))); paramBuf.append(",tbarsize="); paramBuf.append( PEToolKit.doubleToString(defaultAttributes.getAttribute(TBAR_WIDTH_MINIMUM_MM))); paramBuf.append(' '); paramBuf.append( PEToolKit.doubleToString(defaultAttributes.getAttribute(TBAR_WIDTH_LINEWIDTH_SCALE))); paramBuf.append(",bracketlength="); paramBuf.append(PEToolKit.doubleToString(defaultAttributes.getAttribute(BRACKET_LENGTH_SCALE))); paramBuf.append(",rbracketlength="); paramBuf.append( PEToolKit.doubleToString(defaultAttributes.getAttribute(RBRACKET_LENGTH_SCALE))); // dotsize -> see above (polydots) // arrowscale : default to 1 ok paramBuf.append("}"); paramBuf.append(factory.getLineSeparator()); return paramBuf; }