⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 valueaxis.html

📁 jfreechart1。0。2的api。
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<FONT color="green">562</FONT>                    x = cursor;<a name="line.562"></a><FONT color="green">563</FONT>                    y = dataArea.getMaxY();<a name="line.563"></a><FONT color="green">564</FONT>                    arrow = this.downArrow; <a name="line.564"></a><FONT color="green">565</FONT>                }<a name="line.565"></a><FONT color="green">566</FONT>    <a name="line.566"></a><FONT color="green">567</FONT>                // draw the arrow...<a name="line.567"></a><FONT color="green">568</FONT>                AffineTransform transformer = new AffineTransform();<a name="line.568"></a><FONT color="green">569</FONT>                transformer.setToTranslation(x, y);<a name="line.569"></a><FONT color="green">570</FONT>                Shape shape = transformer.createTransformedShape(arrow);<a name="line.570"></a><FONT color="green">571</FONT>                g2.fill(shape);<a name="line.571"></a><FONT color="green">572</FONT>                g2.draw(shape);<a name="line.572"></a><FONT color="green">573</FONT>            }<a name="line.573"></a><FONT color="green">574</FONT>            <a name="line.574"></a><FONT color="green">575</FONT>        }<a name="line.575"></a><FONT color="green">576</FONT>        <a name="line.576"></a><FONT color="green">577</FONT>        /**<a name="line.577"></a><FONT color="green">578</FONT>         * Calculates the anchor point for a tick label.<a name="line.578"></a><FONT color="green">579</FONT>         * <a name="line.579"></a><FONT color="green">580</FONT>         * @param tick  the tick.<a name="line.580"></a><FONT color="green">581</FONT>         * @param cursor  the cursor.<a name="line.581"></a><FONT color="green">582</FONT>         * @param dataArea  the data area.<a name="line.582"></a><FONT color="green">583</FONT>         * @param edge  the edge on which the axis is drawn.<a name="line.583"></a><FONT color="green">584</FONT>         * <a name="line.584"></a><FONT color="green">585</FONT>         * @return The x and y coordinates of the anchor point.<a name="line.585"></a><FONT color="green">586</FONT>         */<a name="line.586"></a><FONT color="green">587</FONT>        protected float[] calculateAnchorPoint(ValueTick tick, <a name="line.587"></a><FONT color="green">588</FONT>                                               double cursor, <a name="line.588"></a><FONT color="green">589</FONT>                                               Rectangle2D dataArea, <a name="line.589"></a><FONT color="green">590</FONT>                                               RectangleEdge edge) {<a name="line.590"></a><FONT color="green">591</FONT>        <a name="line.591"></a><FONT color="green">592</FONT>            RectangleInsets insets = getTickLabelInsets();<a name="line.592"></a><FONT color="green">593</FONT>            float[] result = new float[2];<a name="line.593"></a><FONT color="green">594</FONT>            if (edge == RectangleEdge.TOP) {<a name="line.594"></a><FONT color="green">595</FONT>                result[0] = (float) valueToJava2D(tick.getValue(), dataArea, edge);<a name="line.595"></a><FONT color="green">596</FONT>                result[1] = (float) (cursor - insets.getBottom() - 2.0);<a name="line.596"></a><FONT color="green">597</FONT>            }<a name="line.597"></a><FONT color="green">598</FONT>            else if (edge == RectangleEdge.BOTTOM) {<a name="line.598"></a><FONT color="green">599</FONT>                result[0] = (float) valueToJava2D(tick.getValue(), dataArea, edge);<a name="line.599"></a><FONT color="green">600</FONT>                result[1] = (float) (cursor + insets.getTop() + 2.0); <a name="line.600"></a><FONT color="green">601</FONT>            }<a name="line.601"></a><FONT color="green">602</FONT>            else if (edge == RectangleEdge.LEFT) {<a name="line.602"></a><FONT color="green">603</FONT>                result[0] = (float) (cursor - insets.getLeft() - 2.0);    <a name="line.603"></a><FONT color="green">604</FONT>                result[1] = (float) valueToJava2D(tick.getValue(), dataArea, edge);<a name="line.604"></a><FONT color="green">605</FONT>            }<a name="line.605"></a><FONT color="green">606</FONT>            else if (edge == RectangleEdge.RIGHT) {<a name="line.606"></a><FONT color="green">607</FONT>                result[0] = (float) (cursor + insets.getRight() + 2.0);    <a name="line.607"></a><FONT color="green">608</FONT>                result[1] = (float) valueToJava2D(tick.getValue(), dataArea, edge);<a name="line.608"></a><FONT color="green">609</FONT>            }<a name="line.609"></a><FONT color="green">610</FONT>            return result;<a name="line.610"></a><FONT color="green">611</FONT>        }<a name="line.611"></a><FONT color="green">612</FONT>        <a name="line.612"></a><FONT color="green">613</FONT>        /**<a name="line.613"></a><FONT color="green">614</FONT>         * Draws the axis line, tick marks and tick mark labels.<a name="line.614"></a><FONT color="green">615</FONT>         * <a name="line.615"></a><FONT color="green">616</FONT>         * @param g2  the graphics device.<a name="line.616"></a><FONT color="green">617</FONT>         * @param cursor  the cursor.<a name="line.617"></a><FONT color="green">618</FONT>         * @param plotArea  the plot area.<a name="line.618"></a><FONT color="green">619</FONT>         * @param dataArea  the data area.<a name="line.619"></a><FONT color="green">620</FONT>         * @param edge  the edge that the axis is aligned with.<a name="line.620"></a><FONT color="green">621</FONT>         * <a name="line.621"></a><FONT color="green">622</FONT>         * @return The width or height used to draw the axis.<a name="line.622"></a><FONT color="green">623</FONT>         */<a name="line.623"></a><FONT color="green">624</FONT>        protected AxisState drawTickMarksAndLabels(Graphics2D g2, <a name="line.624"></a><FONT color="green">625</FONT>                                                   double cursor,<a name="line.625"></a><FONT color="green">626</FONT>                                                   Rectangle2D plotArea,<a name="line.626"></a><FONT color="green">627</FONT>                                                   Rectangle2D dataArea, <a name="line.627"></a><FONT color="green">628</FONT>                                                   RectangleEdge edge) {<a name="line.628"></a><FONT color="green">629</FONT>                                                  <a name="line.629"></a><FONT color="green">630</FONT>            AxisState state = new AxisState(cursor);<a name="line.630"></a><FONT color="green">631</FONT>    <a name="line.631"></a><FONT color="green">632</FONT>            if (isAxisLineVisible()) {<a name="line.632"></a><FONT color="green">633</FONT>                drawAxisLine(g2, cursor, dataArea, edge);<a name="line.633"></a><FONT color="green">634</FONT>            }<a name="line.634"></a><FONT color="green">635</FONT>    <a name="line.635"></a><FONT color="green">636</FONT>            double ol = getTickMarkOutsideLength();<a name="line.636"></a><FONT color="green">637</FONT>            double il = getTickMarkInsideLength();<a name="line.637"></a><FONT color="green">638</FONT>    <a name="line.638"></a><FONT color="green">639</FONT>            List ticks = refreshTicks(g2, state, dataArea, edge);<a name="line.639"></a><FONT color="green">640</FONT>            state.setTicks(ticks);<a name="line.640"></a><FONT color="green">641</FONT>            g2.setFont(getTickLabelFont());<a name="line.641"></a><FONT color="green">642</FONT>            Iterator iterator = ticks.iterator();<a name="line.642"></a><FONT color="green">643</FONT>            while (iterator.hasNext()) {<a name="line.643"></a><FONT color="green">644</FONT>                ValueTick tick = (ValueTick) iterator.next();<a name="line.644"></a><FONT color="green">645</FONT>                if (isTickLabelsVisible()) {<a name="line.645"></a><FONT color="green">646</FONT>                    g2.setPaint(getTickLabelPaint());<a name="line.646"></a><FONT color="green">647</FONT>                    float[] anchorPoint = calculateAnchorPoint(<a name="line.647"></a><FONT color="green">648</FONT>                        tick, cursor, dataArea, edge<a name="line.648"></a><FONT color="green">649</FONT>                    );<a name="line.649"></a><FONT color="green">650</FONT>                    TextUtilities.drawRotatedString(<a name="line.650"></a><FONT color="green">651</FONT>                        tick.getText(), g2, <a name="line.651"></a><FONT color="green">652</FONT>                        anchorPoint[0], anchorPoint[1],<a name="line.652"></a><FONT color="green">653</FONT>                        tick.getTextAnchor(), <a name="line.653"></a><FONT color="green">654</FONT>                        tick.getAngle(),<a name="line.654"></a><FONT color="green">655</FONT>                        tick.getRotationAnchor()<a name="line.655"></a><FONT color="green">656</FONT>                    );<a name="line.656"></a><FONT color="green">657</FONT>                }<a name="line.657"></a><FONT color="green">658</FONT>    <a name="line.658"></a><FONT color="green">659</FONT>                if (isTickMarksVisible()) {<a name="line.659"></a><FONT color="green">660</FONT>                    float xx = (float) valueToJava2D(<a name="line.660"></a><FONT color="green">661</FONT>                        tick.getValue(), dataArea, edge<a name="line.661"></a><FONT color="green">662</FONT>                    );<a name="line.662"></a><FONT color="green">663</FONT>                    Line2D mark = null;<a name="line.663"></a><FONT color="green">664</FONT>                    g2.setStroke(getTickMarkStroke());<a name="line.664"></a><FONT color="green">665</FONT>                    g2.setPaint(getTickMarkPaint());<a name="line.665"></a><FONT color="green">666</FONT>                    if (edge == RectangleEdge.LEFT) {<a name="line.666"></a><FONT color="green">667</FONT>                        mark = new Line2D.Double(cursor - ol, xx, cursor + il, xx);<a name="line.667"></a><FONT color="green">668</FONT>                    }<a name="line.668"></a><FONT color="green">669</FONT>                    else if (edge == RectangleEdge.RIGHT) {<a name="line.669"></a><FONT color="green">670</FONT>                        mark = new Line2D.Double(cursor + ol, xx, cursor - il, xx);<a name="line.670"></a><FONT color="green">671</FONT>                    }<a name="line.671"></a><FONT color="green">672</FONT>                    else if (edge == RectangleEdge.TOP) {<a name="line.672"></a><FONT color="green">673</FONT>                        mark = new Line2D.Double(xx, cursor - ol, xx, cursor + il);<a name="line.673"></a><FONT color="green">674</FONT>                    }<a name="line.674"></a><FONT color="green">675</FONT>                    else if (edge == RectangleEdge.BOTTOM) {<a name="line.675"></a><FONT color="green">676</FONT>                        mark = new Line2D.Double(xx, cursor + ol, xx, cursor - il);<a name="line.676"></a><FONT color="green">677</FONT>                    }<a name="line.677"></a><FONT color="green">678</FONT>                    g2.draw(mark);<a name="line.678"></a><FONT color="green">679</FONT>                }<a name="line.679"></a><FONT color="green">680</FONT>            }<a name="line.680"></a><FONT color="green">681</FONT>            <a name="line.681"></a><FONT color="green">682</FONT>            // need to work out the space used by the tick labels...<a name="line.682"></a><FONT color="green">683</FONT>            // so we can update the cursor...<a name="line.683"></a><FONT color="green">684</FONT>            double used = 0.0;<a name="line.684"></a><FONT color="green">685</FONT>            if (isTickLabelsVisible()) {<a name="line.685"></a><FONT color="green">686</FONT>                if (edge == RectangleEdge.LEFT) {<a name="line.686"></a><FONT color="green">687</FONT>                    used += findMaximumTickLabelWidth(<a name="line.687"></a><FONT color="green">688</FONT>                        ticks, g2, plotArea, isVerticalTickLabels()<a name="line.688"></a><FONT color="green">689</FONT>                    );  <a name="line.689"></a><FONT color="green">690</FONT>                    state.cursorLeft(used);      <a name="line.690"></a><FONT color="green">691</FONT>                }<a name="line.691"></a><FONT color="green">692</FONT>                else if (edge == RectangleEdge.RIGHT) {<a name="line.692"></a><FONT color="green">693</FONT>                    used = findMaximumTickLabelWidth(<a name="line.693"></a><FONT color="green">694</FONT>                        ticks, g2, plotArea, isVerticalTickLabels()<a name="line.694"></a><FONT color="green">695</FONT>                    );<a name="line.695"></a><FONT color="green">696</FONT>                    state.cursorRight(used);      <a name="line.696"></a><FONT color="green">697</FONT>                }<a name="line.697"></a><FONT color="green">698</FONT>                else if (edge == RectangleEdge.TOP) {<a name="line.698"></a><FONT color="green">699</FONT>                    used = findMaximumTickLabelHeight(<a name="line.699"></a><FONT color="green">700</FONT>                        ticks, g2, plotArea, isVerticalTickLabels()<a name="line.700"></a><FONT color="green">701</FONT>                    );<a name="line.701"></a><FONT color="green">70

⌨️ 快捷键说明

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