minmaxcategoryrenderer.java

来自「JfreeChart 常用图表例子」· Java 代码 · 共 501 行 · 第 1/2 页

JAVA
501
字号
                EntityCollection entities                     = state.getInfo().getOwner().getEntityCollection();                if (entities != null && shape != null) {                    String tip = null;                    CategoryToolTipGenerator tipster                         = getToolTipGenerator(row, column);                    if (tipster != null) {                        tip = tipster.generateToolTip(dataset, row, column);                    }                    CategoryItemEntity entity = new CategoryItemEntity(                        shape, tip, null, dataset, row,                         dataset.getColumnKey(column), column);                    entities.add(entity);                }            }        }    }    /**     * Sets whether or not lines are drawn between category points.     *     * @param drawLines  if true, then line will be drawn between sequenced      *                   categories.     */    public void setDrawLines (boolean drawLines) {        this.plotLines = drawLines;    }    /**     * Gets whether or not lines are drawn between category points.     *     * @return boolean true if line will be drawn between sequenced categories,     *         otherwise false.     */    public boolean isDrawLines () {        return this.plotLines;    }    /**     * Sets the paint of the line between the minimum value and the maximum      * value.     *     * @param groupPaint  the new paint.     */    public void setGroupPaint (Paint groupPaint) {        this.groupPaint = groupPaint;    }    /**     * Gets the paint of the line between the minimum value and the maximum      * value.     *     * @return The paint.     */    public Paint getGroupPaint () {        return this.groupPaint;    }    /**     * Sets the stroke of the line between the minimum value and the maximum      * value.     *     * @param groupStroke The new stroke     */    public void setGroupStroke (Stroke groupStroke) {        this.groupStroke = groupStroke;    }    /**     * Gets the stroke of the line between the minimum value and the maximum      * value.     *     * @return Stroke The current stroke.     */    public Stroke getGroupStroke () {        return this.groupStroke;    }    /**     * Sets the icon used to indicate the values.     *     * @param objectIcon  the icon.     */    public void setObjectIcon (Icon objectIcon) {        this.objectIcon = objectIcon;    }    /**     * Gets the icon used to indicate the values.     *     * @return The icon.     */    public Icon getObjectIcon () {        return this.objectIcon;    }    /**     * Sets the icon used to indicate the maximum value.     *     * @param maxIcon  the max icon.     */    public void setMaxIcon (Icon maxIcon) {        this.maxIcon = maxIcon;    }    /**     * Gets the icon used to indicate the maximum value.     *     * @return The icon     */    public Icon getMaxIcone () {        return this.maxIcon;    }    /**     * Sets the icon used to indicate the minimum value.     *     * @param minIcon  the min icon.     */    public void setMinIcon (Icon minIcon) {        this.minIcon = minIcon;    }    /**     * Gets the icon used to indicate the minimum value.     *     * @return Icon     */    public Icon getMinIcon () {        return this.minIcon;    }    /**     * Returns an icon.     *     * @param shape  the shape.     * @param fillPaint  the fill paint.     * @param outlinePaint  the outline paint.     *     * @return The icon.     */    private Icon getIcon(Shape shape, final Paint fillPaint,                         final Paint outlinePaint) {      final int width = shape.getBounds().width;      final int height = shape.getBounds().height;      final GeneralPath path = new GeneralPath(shape);      return new Icon() {          public void paintIcon(Component c, Graphics g, int x, int y) {              Graphics2D g2 = (Graphics2D) g;              path.transform(AffineTransform.getTranslateInstance(x, y));              if (fillPaint != null) {                  g2.setPaint(fillPaint);                  g2.fill(path);              }              if (outlinePaint != null) {                  g2.setPaint(outlinePaint);                  g2.draw(path);              }              path.transform(AffineTransform.getTranslateInstance(-x, -y));        }        public int getIconWidth() {            return width;        }        public int getIconHeight() {            return height;        }      };    }    /**     * Returns an icon.     *     * @param shape  the shape.     * @param fill  the fill flag.     * @param outline  the outline flag.     *     * @return The icon.     */    private Icon getIcon(Shape shape, final boolean fill,                          final boolean outline) {        final int width = shape.getBounds().width;        final int height = shape.getBounds().height;        final GeneralPath path = new GeneralPath(shape);        return new Icon() {            public void paintIcon(Component c, Graphics g, int x, int y) {                Graphics2D g2 = (Graphics2D) g;                path.transform(AffineTransform.getTranslateInstance(x, y));                if (fill) {                    g2.fill(path);                }                if (outline) {                    g2.draw(path);                }                path.transform(AffineTransform.getTranslateInstance(-x, -y));            }            public int getIconWidth() {                return width;            }            public int getIconHeight() {                return height;            }        };    }        /**     * Provides serialization support.     *     * @param stream  the output stream.     *     * @throws IOException  if there is an I/O error.     */    private void writeObject(ObjectOutputStream stream) throws IOException {        stream.defaultWriteObject();        SerialUtilities.writeStroke(this.groupStroke, stream);        SerialUtilities.writePaint(this.groupPaint, stream);    }        /**     * Provides serialization support.     *     * @param stream  the input stream.     *     * @throws IOException  if there is an I/O error.     * @throws ClassNotFoundException  if there is a classpath problem.     */    private void readObject(ObjectInputStream stream)         throws IOException, ClassNotFoundException {        stream.defaultReadObject();        this.groupStroke = SerialUtilities.readStroke(stream);        this.groupPaint = SerialUtilities.readPaint(stream);                  this.minIcon = getIcon(            new Arc2D.Double(-4, -4, 8, 8, 0, 360, Arc2D.OPEN), null,             Color.black        );        this.maxIcon = getIcon(            new Arc2D.Double(-4, -4, 8, 8, 0, 360, Arc2D.OPEN), null,             Color.black        );        this.objectIcon = getIcon(new Line2D.Double(-4, 0, 4, 0), false, true);    }    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?