📄 axisparameters.java
字号:
* <td><tt>ConfigParameters</tt></td><td>no</td> * <td>Attributes of the axis box.</td></tr> * <tr><td><tt>axisLabel = x</tt></td> * <td><tt>String</tt></td><td>no</td> * <td>Axis label.</td></tr> * <tr><td><tt>axisLabelAttributes = </tt>default values of * {@link BasicGraphicAttributes} with a text anchor CENTER * TOP.</td> * <td><tt>ConfigParameters</tt></td><td>no</td> * <td>Text attributes of axis label.</td></tr> * <tr><td><tt>axisLabelPosition = 0 -0.05</tt></td> * <td><tt>double[]</tt></td><td>no</td> * <td>Position of the anchor of the axis * label relative to the center of the x-axis line.</td></tr> * <tr><td><tt>axisLength = 0.8</tt></td> * <td><tt>double</tt></td><td>no</td> * <td>Length of the x-axis.</td></tr> * <tr><td><tt>grid = false</tt></td> * <td><tt>boolean</tt></td><td>no</td> * <td>If <tt>true</tt> grid lines will be drawn through the axis * tics.</td></tr> * <tr><td><tt>gridAttributes = </tt>default values of * {@link ShapeAttributes}</td> * <td><tt>ConfigParameters</tt></td><td>no</td> * <td>Attributes of the grid lines.</td></tr> * <tr><td><tt>logScale = false</tt></td> * <td><tt>boolean</tt></td><td>no</td> * <td>If <tt>true</tt> the axis will be logarithmic. Otherwise * the axis is linear.</td></tr> * <tr><td><tt>maximum = 1</tt></td> * <td><tt>double</tt></td><td>no</td> * <td>The corresponding data value of one end of the axis.</td></tr> * <tr><td><tt>maximumTic = </tt>result from automatic calculation</td> * <td><tt>double</tt></td><td>no</td> * <td>The corresponding data value of the tic nearest the maximum end * of the axis.</td></tr> * <tr><td><tt>minimum = 0</tt></td> * <td><tt>double</tt></td><td>no</td> * <td>The corresponding data value of one end of the axis.</td></tr> * <tr><td><tt>minimumTic = </tt>result from automatic calculation</td> * <td><tt>double</tt></td><td>no</td> * <td>The corresponding data value of the tic nearest the minimum end * of the axis.</td></tr> * <tr><td><tt>numberOfTics = </tt>result from automatic calculation</td> * <td><tt>int</tt></td><td>no</td> * <td>Number of tics. The tics between the minimum and maximum tic * are spaced equidistantly.</td></tr> * <tr><td><tt>ticAttributes = </tt>default values of * {@link ShapeAttributes}</td> * <td><tt>ConfigParameters</tt></td><td>no</td> * <td>Attributes of the tics.</td></tr> * <tr><td><tt>ticLabelAttributes = </tt>default values of * {@link BasicGraphicAttributes} with a text anchor CENTER * TOP.</td> * <td><tt>ConfigParameters</tt></td><td>no</td> * <td>Text attributes of tic labels.</td></tr> * <tr><td><tt>ticLabelFormat = %1.1f</tt></td> * <td><tt>String</tt> or <tt>ConfigParameters</tt></td><td>no</td> * <td>Defines rendering of the tic label. By default a * <tt>printf</tt>-like format string is given (see {@link Format}). * Note, that an empty string means that tic labels are dropped. * <p> * For non-numerical rendering an implementation of a * {@link TicLabelFormat} can be specified (e.g. * {@link TicLabelMap}). Note, that a configuration sub tree with * a <tt>className</tt> key-value pair overwrites any string * definition.</td></tr> * <tr><td><tt>ticLabelPosition = 0 -0.01</tt></td> * <td><tt>double[]</tt></td><td>no</td> * <td>Position of the anchor of the tic label relative to the * tic position on the axis.</td></tr> * <tr><td><tt>ticLength = 0.01</tt></td> * <td><tt>double</tt></td><td>no</td> * <td>Length of the tics. Negative/positive values mean tics * inside/outside the box.</td></tr> * </table> */ public static AxisParameters createXAxis(ConfigParameters config) { return createAxis(config, createDefaultXAxisProperties()); } /** * Returns a <tt>Properties</tt> object of the default parameters for * an x-axis. */ private static Properties createDefaultYAxisProperties() { Properties p = createDefaultAxisProperties(); p.put(AXIS_LENGTH_KEY, "0.45"); p.put(AXIS_LABEL_KEY, "y"); p.put(AXIS_LABEL_POSITION_KEY, "-0.1 0"); p.put(AXIS_LABEL_ATTRIBUTES_KEY + '/' + BasicGraphicAttributes.VERTICAL_ANCHOR_KEY, "bottom"); p.put(AXIS_LABEL_ATTRIBUTES_KEY + '/' + BasicGraphicAttributes.ORIENTATION_ANGLE_KEY, "90"); p.put(TIC_LABEL_POSITION_KEY, "-0.01 0"); p.put(TIC_LABEL_ATTRIBUTES_KEY + '/' + BasicGraphicAttributes.HORIZONTAL_ANCHOR_KEY, "right"); p.put(TIC_LABEL_ATTRIBUTES_KEY + '/' + BasicGraphicAttributes.VERTICAL_ANCHOR_KEY, "center"); return p; } /** * Creates an y axis based on the specified configuration parameters. * All numbers (lengths, fontsizes, linethicknesses, etc.) are in * device-independent units. * <table border=1 cellpadding=5> * <tr><th>Key & Default Value</th><th>Type</th><th>Mandatory</th> * <th>Description</th></tr> * <tr><td><tt>automaticTicCalculation = true</tt></td> * <td><tt>boolean</tt></td><td>no</td> * <td>Has to be <tt>true</tt> if the tics should be calculated * automatically.</td></tr> * <tr><td><tt>axisAttributes = </tt>default values of * {@link ShapeAttributes}</td> * <td><tt>ConfigParameters</tt></td><td>no</td> * <td>Attributes of the axis box.</td></tr> * <tr><td><tt>axisLabel = y</tt></td> * <td><tt>String</tt></td><td>no</td> * <td>Axis label.</td></tr> * <tr><td><tt>axisLabelAttributes = </tt>default values of * {@link BasicGraphicAttributes} with a text anchor CENTER * BOTTOM and the text rotated by 90 degree.</td> * <td><tt>ConfigParameters</tt></td><td>no</td> * <td>Text attributes of axis label.</td></tr> * <tr><td><tt>axisLabelPosition = -0.1 0</tt></td> * <td><tt>double[]</tt></td><td>no</td> * <td>Position of the anchor of the axis * label relative to the center of the y-axis line.</td></tr> * <tr><td><tt>axisLength = 0.45</tt></td> * <td><tt>double</tt></td><td>no</td> * <td>Length of the y-axis.</td></tr> * <tr><td><tt>grid = false</tt></td> * <td><tt>boolean</tt></td><td>no</td> * <td>If <tt>true</tt> grid lines will be drawn through the axis * tics.</td></tr> * <tr><td><tt>gridAttributes = </tt>default values of * {@link ShapeAttributes}</td> * <td><tt>ConfigParameters</tt></td><td>no</td> * <td>Attributes of the grid lines.</td></tr> * <tr><td><tt>logScale = false</tt></td> * <td><tt>boolean</tt></td><td>no</td> * <td>If <tt>true</tt> the axis will be logarithmic. Otherwise * the axis is linear.</td></tr> * <tr><td><tt>maximum = 1</tt></td> * <td><tt>double</tt></td><td>no</td> * <td>The corresponding data value of one end of the axis.</td></tr> * <tr><td><tt>maximumTic = </tt>result from automatic calculation</td> * <td><tt>double</tt></td><td>no</td> * <td>The corresponding data value of the tic nearest the maximum end * of the axis.</td></tr> * <tr><td><tt>minimum = 0</tt></td> * <td><tt>double</tt></td><td>no</td> * <td>The corresponding data value of one end of the axis.</td></tr> * <tr><td><tt>minimumTic = </tt>result from automatic calculation</td> * <td><tt>double</tt></td><td>no</td> * <td>The corresponding data value of the tic nearest the minimum end * of the axis.</td></tr> * <tr><td><tt>numberOfTics = </tt>result from automatic calculation</td> * <td><tt>int</tt></td><td>no</td> * <td>Number of tics. The tics between the minimum and maximum tic * are spaced equidistantly.</td></tr> * <tr><td><tt>ticAttributes = </tt>default values of * {@link ShapeAttributes}</td> * <td><tt>ConfigParameters</tt></td><td>no</td> * <td>Attributes of the tics.</td></tr> * <tr><td><tt>ticLabelAttributes = </tt>default values of * {@link BasicGraphicAttributes} with a text anchor RIGHT CENTER. * </td> * <td><tt>ConfigParameters</tt></td><td>no</td> * <td>Text attributes of tic labels.</td></tr> * <tr><td><tt>ticLabelFormat = %1.1f</tt></td> * <td><tt>String</tt></td><td>no</td> * <td>Defines rendering of the tic label. By default a * <tt>printf</tt>-like format string is given (see {@link Format}). * Note, that an empty string means that tic labels are dropped. * <p> * For non-numerical rendering an implementation of a * {@link TicLabelFormat} can be specified (e.g. * {@link TicLabelMap}). Note, that a configuration sub tree with * a <tt>className</tt> key-value pair overwrites any string * definition.</td></tr> * <tr><td><tt>ticLabelPosition = -0.01 0</tt></td> * <td><tt>double[]</tt></td><td>no</td> * <td>Position of the anchor of the tic label relative to the * tic position on the axis.</td></tr> * <tr><td><tt>ticLength = 0.01</tt></td> * <td><tt>double</tt></td><td>no</td> * <td>Length of the tics. Negative/positive values mean tics * inside/outside the box.</td></tr> * </table> */ public static AxisParameters createYAxis(ConfigParameters config) { return createAxis(config, createDefaultYAxisProperties()); } private static AxisParameters createAxis(ConfigParameters config, Properties p) { ConfigData cd = new PropertiesBasedConfigData(p); ConfigParameters c = new ConfigParameters(cd); cd = new ConfigParametersBasedConfigData(config, c); c = new ConfigParameters(cd); AxisParameters a = new AxisParameters(); a.logScale = c.getBoolean(LOG_SCALE_KEY); a.minimum = c.getDouble(MINIMUM_KEY); a.maximum = c.getDouble(MAXIMUM_KEY); a.axisLength = c.getDouble(AXIS_LENGTH_KEY); a.axisAttributes = (LineAttributes) Factory.create(c.getNode(AXIS_ATTRIBUTES_KEY)); a.axisLabel = c.get(AXIS_LABEL_KEY); a.axisLabelPosition = new GraphPoint(c.getDoubleArray(AXIS_LABEL_POSITION_KEY)); a.axisLabelAttributes = (TextAttributes) Factory.create( c.getNode(AXIS_LABEL_ATTRIBUTES_KEY)); a.ticLength = c.getDouble(TIC_LENGTH_KEY); a.automaticTicCalculation = c.getBoolean(AUTOMATIC_TIC_CALCULATION_KEY); if (!a.automaticTicCalculation) { a.calculateTicsParameters(); // calculate default parameters a.minimumTic = c.getDouble(MINIMUM_TIC_KEY, a.minimumTic); a.maximumTic = c.getDouble(MAXIMUM_TIC_KEY, a.maximumTic); a.numberOfTics = c.getInt(NUMBER_OF_TICS_KEY, a.numberOfTics); } a.ticAttributes = (LineAttributes) Factory.create(c.getNode(TIC_ATTRIBUTES_KEY)); a.ticLabelFormat = createTicLabelFormat(c); a.ticLabelPosition = new GraphPoint(c.getDoubleArray(TIC_LABEL_POSITION_KEY)); a.ticLabelAttributes = (TextAttributes) Factory.create( c.getNode(TIC_LABEL_ATTRIBUTES_KEY)); a.grid = c.getBoolean(GRID_KEY); a.gridAttributes = (LineAttributes) Factory.create(c.getNode(GRID_ATTRIBUTES_KEY)); return a; } private static TicLabelFormat createTicLabelFormat(ConfigParameters c) { TicLabelFormat result = Format.create(c, TIC_LABEL_FORMAT_KEY); ConfigParameters node = c.getNode(TIC_LABEL_FORMAT_KEY); if (node.get(Factory.CLASS_NAME_KEY, null) != null) { result = (TicLabelFormat) Factory.create(node); } return result; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -