Java Code Examples for org.jfree.chart.util.RectangleEdge#TOP

The following examples show how to use org.jfree.chart.util.RectangleEdge#TOP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: 1_BorderArrangement.java    From SimFix with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds a block to the arrangement manager at the specified edge.
 *
 * @param block  the block (<code>null</code> permitted).
 * @param key  the edge (an instance of {@link RectangleEdge}) or
 *             <code>null</code> for the center block.
 */
public void add(Block block, Object key) {

    if (key == null) {
        this.centerBlock = block;
    }
    else {
        RectangleEdge edge = (RectangleEdge) key;
        if (edge == RectangleEdge.TOP) {
            this.topBlock = block;
        }
        else if (edge == RectangleEdge.BOTTOM) {
            this.bottomBlock = block;
        }
        else if (edge == RectangleEdge.LEFT) {
            this.leftBlock = block;
        }
        else if (edge == RectangleEdge.RIGHT) {
            this.rightBlock = block;
        }
    }
}
 
Example 2
Source File: CategoryLabelPositions.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the category label position specification for an axis at the 
 * given location.
 * 
 * @param edge  the axis location.
 * 
 * @return The category label position specification.
 */
public CategoryLabelPosition getLabelPosition(RectangleEdge edge) {
    CategoryLabelPosition result = null;
    if (edge == RectangleEdge.TOP) {
        result = this.positionForAxisAtTop;
    }
    else if (edge == RectangleEdge.BOTTOM) {
        result = this.positionForAxisAtBottom;
    }
    else if (edge == RectangleEdge.LEFT) {
        result = this.positionForAxisAtLeft;
    }
    else if (edge == RectangleEdge.RIGHT) {
        result = this.positionForAxisAtRight;
    }
    return result;
}
 
Example 3
Source File: JGenProg2017_0045_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Adds a block to the arrangement manager at the specified edge.
 *
 * @param block  the block (<code>null</code> permitted).
 * @param key  the edge (an instance of {@link RectangleEdge}) or
 *             <code>null</code> for the center block.
 */
public void add(Block block, Object key) {

    if (key == null) {
        this.centerBlock = block;
    }
    else {
        RectangleEdge edge = (RectangleEdge) key;
        if (edge == RectangleEdge.TOP) {
            this.topBlock = block;
        }
        else if (edge == RectangleEdge.BOTTOM) {
            this.bottomBlock = block;
        }
        else if (edge == RectangleEdge.LEFT) {
            this.leftBlock = block;
        }
        else if (edge == RectangleEdge.RIGHT) {
            this.rightBlock = block;
        }
    }
}
 
Example 4
Source File: Chart_13_BorderArrangement_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Adds a block to the arrangement manager at the specified edge.
 *
 * @param block  the block (<code>null</code> permitted).
 * @param key  the edge (an instance of {@link RectangleEdge}) or
 *             <code>null</code> for the center block.
 */
public void add(Block block, Object key) {

    if (key == null) {
        this.centerBlock = block;
    }
    else {
        RectangleEdge edge = (RectangleEdge) key;
        if (edge == RectangleEdge.TOP) {
            this.topBlock = block;
        }
        else if (edge == RectangleEdge.BOTTOM) {
            this.bottomBlock = block;
        }
        else if (edge == RectangleEdge.LEFT) {
            this.leftBlock = block;
        }
        else if (edge == RectangleEdge.RIGHT) {
            this.rightBlock = block;
        }
    }
}
 
Example 5
Source File: JGenProg2017_002_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Adds a block to the arrangement manager at the specified edge.
 *
 * @param block  the block (<code>null</code> permitted).
 * @param key  the edge (an instance of {@link RectangleEdge}) or
 *             <code>null</code> for the center block.
 */
public void add(Block block, Object key) {

    if (key == null) {
        this.centerBlock = block;
    }
    else {
        RectangleEdge edge = (RectangleEdge) key;
        if (edge == RectangleEdge.TOP) {
            this.topBlock = block;
        }
        else if (edge == RectangleEdge.BOTTOM) {
            this.bottomBlock = block;
        }
        else if (edge == RectangleEdge.LEFT) {
            this.leftBlock = block;
        }
        else if (edge == RectangleEdge.RIGHT) {
            this.rightBlock = block;
        }
    }
}
 
Example 6
Source File: Cardumen_00195_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws an axis line at the current cursor position and edge.
 * 
 * @param g2  the graphics device.
 * @param cursor  the cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawAxisLine(Graphics2D g2, double cursor,
        Rectangle2D dataArea, RectangleEdge edge) {
    
    Line2D axisLine = null;
    if (edge == RectangleEdge.TOP) {
        axisLine = new Line2D.Double(dataArea.getX(), cursor, 
                dataArea.getMaxX(), cursor);  
    }
    else if (edge == RectangleEdge.BOTTOM) {
        axisLine = new Line2D.Double(dataArea.getX(), cursor, 
                dataArea.getMaxX(), cursor);  
    }
    else if (edge == RectangleEdge.LEFT) {
        axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, 
                dataArea.getMaxY());  
    }
    else if (edge == RectangleEdge.RIGHT) {
        axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, 
                dataArea.getMaxY());  
    }
    g2.setPaint(this.axisLinePaint);
    g2.setStroke(this.axisLineStroke);
    g2.draw(axisLine);
    
}
 
Example 7
Source File: jMutRepair_0038_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws an axis line at the current cursor position and edge.
 * 
 * @param g2  the graphics device.
 * @param cursor  the cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawAxisLine(Graphics2D g2, double cursor,
        Rectangle2D dataArea, RectangleEdge edge) {
    
    Line2D axisLine = null;
    if (edge == RectangleEdge.TOP) {
        axisLine = new Line2D.Double(dataArea.getX(), cursor, 
                dataArea.getMaxX(), cursor);  
    }
    else if (edge == RectangleEdge.BOTTOM) {
        axisLine = new Line2D.Double(dataArea.getX(), cursor, 
                dataArea.getMaxX(), cursor);  
    }
    else if (edge == RectangleEdge.LEFT) {
        axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, 
                dataArea.getMaxY());  
    }
    else if (edge == RectangleEdge.RIGHT) {
        axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, 
                dataArea.getMaxY());  
    }
    g2.setPaint(this.axisLinePaint);
    g2.setStroke(this.axisLineStroke);
    g2.draw(axisLine);
    
}
 
Example 8
Source File: Cardumen_0080_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws an axis line at the current cursor position and edge.
 * 
 * @param g2  the graphics device.
 * @param cursor  the cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawAxisLine(Graphics2D g2, double cursor,
        Rectangle2D dataArea, RectangleEdge edge) {
    
    Line2D axisLine = null;
    if (edge == RectangleEdge.TOP) {
        axisLine = new Line2D.Double(dataArea.getX(), cursor, 
                dataArea.getMaxX(), cursor);  
    }
    else if (edge == RectangleEdge.BOTTOM) {
        axisLine = new Line2D.Double(dataArea.getX(), cursor, 
                dataArea.getMaxX(), cursor);  
    }
    else if (edge == RectangleEdge.LEFT) {
        axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, 
                dataArea.getMaxY());  
    }
    else if (edge == RectangleEdge.RIGHT) {
        axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, 
                dataArea.getMaxY());  
    }
    g2.setPaint(this.axisLinePaint);
    g2.setStroke(this.axisLineStroke);
    g2.draw(axisLine);
    
}
 
Example 9
Source File: jKali_0032_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws an axis line at the current cursor position and edge.
 * 
 * @param g2  the graphics device.
 * @param cursor  the cursor position.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawAxisLine(Graphics2D g2, double cursor,
        Rectangle2D dataArea, RectangleEdge edge) {
    
    Line2D axisLine = null;
    if (edge == RectangleEdge.TOP) {
        axisLine = new Line2D.Double(dataArea.getX(), cursor, 
                dataArea.getMaxX(), cursor);  
    }
    else if (edge == RectangleEdge.BOTTOM) {
        axisLine = new Line2D.Double(dataArea.getX(), cursor, 
                dataArea.getMaxX(), cursor);  
    }
    else if (edge == RectangleEdge.LEFT) {
        axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, 
                dataArea.getMaxY());  
    }
    else if (edge == RectangleEdge.RIGHT) {
        axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, 
                dataArea.getMaxY());  
    }
    g2.setPaint(this.axisLinePaint);
    g2.setStroke(this.axisLineStroke);
    g2.draw(axisLine);
    
}
 
Example 10
Source File: AxisCollection.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an axis to the collection.
 * 
 * @param axis  the axis (<code>null</code> not permitted).
 * @param edge  the edge of the plot that the axis should be drawn on 
 *              (<code>null</code> not permitted).
 */
public void add(Axis axis, RectangleEdge edge) {
    if (axis == null) {
        throw new IllegalArgumentException("Null 'axis' argument.");   
    }
    if (edge == null) {
        throw new IllegalArgumentException("Null 'edge' argument.");   
    }
    if (edge == RectangleEdge.TOP) {
        this.axesAtTop.add(axis);
    }
    else if (edge == RectangleEdge.BOTTOM) {
        this.axesAtBottom.add(axis);
    }
    else if (edge == RectangleEdge.LEFT) {
        this.axesAtLeft.add(axis);
    }
    else if (edge == RectangleEdge.RIGHT) {
        this.axesAtRight.add(axis);
    }
}
 
Example 11
Source File: Cardumen_0076_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Adds a block to the arrangement manager at the specified edge.
 *
 * @param block  the block (<code>null</code> permitted).
 * @param key  the edge (an instance of {@link RectangleEdge}) or
 *             <code>null</code> for the center block.
 */
public void add(Block block, Object key) {

    if (key == null) {
        this.centerBlock = block;
    }
    else {
        RectangleEdge edge = (RectangleEdge) key;
        if (edge == RectangleEdge.TOP) {
            this.topBlock = block;
        }
        else if (edge == RectangleEdge.BOTTOM) {
            this.bottomBlock = block;
        }
        else if (edge == RectangleEdge.LEFT) {
            this.leftBlock = block;
        }
        else if (edge == RectangleEdge.RIGHT) {
            this.rightBlock = block;
        }
    }
}
 
Example 12
Source File: TextTitle.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws a the title horizontally within the specified area.  This method 
 * will be called from the {@link #draw(Graphics2D, Rectangle2D) draw} 
 * method.
 * 
 * @param g2  the graphics device.
 * @param area  the area for the title.
 */
protected void drawHorizontal(Graphics2D g2, Rectangle2D area) {
    Rectangle2D titleArea = (Rectangle2D) area.clone();
    g2.setFont(this.font);
    g2.setPaint(this.paint);
    TextBlockAnchor anchor = null;
    float x = 0.0f;
    HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
    if (horizontalAlignment == HorizontalAlignment.LEFT) {
        x = (float) titleArea.getX();
        anchor = TextBlockAnchor.TOP_LEFT;
    }
    else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
        x = (float) titleArea.getMaxX();
        anchor = TextBlockAnchor.TOP_RIGHT;
    }
    else if (horizontalAlignment == HorizontalAlignment.CENTER) {
        x = (float) titleArea.getCenterX();
        anchor = TextBlockAnchor.TOP_CENTER;
    }
    float y = 0.0f;
    RectangleEdge position = getPosition();
    if (position == RectangleEdge.TOP) {
        y = (float) titleArea.getY();
    }
    else if (position == RectangleEdge.BOTTOM) {
        y = (float) titleArea.getMaxY();
        if (horizontalAlignment == HorizontalAlignment.LEFT) {
            anchor = TextBlockAnchor.BOTTOM_LEFT;
        }
        else if (horizontalAlignment == HorizontalAlignment.CENTER) {
            anchor = TextBlockAnchor.BOTTOM_CENTER;
        }
        else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
            anchor = TextBlockAnchor.BOTTOM_RIGHT;
        }
    }
    this.content.draw(g2, x, y, anchor);
}
 
Example 13
Source File: NumberAxis3D.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the axis on a Java 2D graphics device (such as the screen or a
 * printer).
 *
 * @param g2  the graphics device.
 * @param cursor  the cursor.
 * @param plotArea  the area for drawing the axes and data.
 * @param dataArea  the area for drawing the data (a subset of the
 *                  plotArea).
 * @param edge  the axis location.
 * @param plotState  collects information about the plot (<code>null</code>
 *                   permitted).
 *
 * @return The updated cursor value.
 */
public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea,
        Rectangle2D dataArea, RectangleEdge edge,
        PlotRenderingInfo plotState) {

    // if the axis is not visible, don't draw it...
    if (!isVisible()) {
        AxisState state = new AxisState(cursor);
        // even though the axis is not visible, we need ticks for the
        // gridlines...
        List ticks = refreshTicks(g2, state, dataArea, edge);
        state.setTicks(ticks);
        return state;
    }

    // calculate the adjusted data area taking into account the 3D effect...
    double xOffset = 0.0;
    double yOffset = 0.0;
    Plot plot = getPlot();
    if (plot instanceof CategoryPlot) {
        CategoryPlot cp = (CategoryPlot) plot;
        CategoryItemRenderer r = cp.getRenderer();
        if (r instanceof Effect3D) {
            Effect3D e3D = (Effect3D) r;
            xOffset = e3D.getXOffset();
            yOffset = e3D.getYOffset();
        }
    }

    double adjustedX = dataArea.getMinX();
    double adjustedY = dataArea.getMinY();
    double adjustedW = dataArea.getWidth() - xOffset;
    double adjustedH = dataArea.getHeight() - yOffset;

    if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
        adjustedY += yOffset;
    }
    else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
        adjustedX += xOffset;
    }
    Rectangle2D adjustedDataArea = new Rectangle2D.Double(adjustedX,
            adjustedY, adjustedW, adjustedH);

    // draw the tick marks and labels...
    AxisState info = drawTickMarksAndLabels(g2, cursor, plotArea,
            adjustedDataArea, edge, plotState);

    // draw the axis label...
    info = drawLabel(getLabel(), g2, plotArea, dataArea, edge, info,
            plotState);

    return info;

}
 
Example 14
Source File: StandardXYBarPainter.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a shadow for the bar.
 *
 * @param bar  the bar shape.
 * @param xOffset  the x-offset for the shadow.
 * @param yOffset  the y-offset for the shadow.
 * @param base  the edge that is the base of the bar.
 * @param pegShadow  peg the shadow to the base?
 *
 * @return A rectangle for the shadow.
 */
private Rectangle2D createShadow(RectangularShape bar, double xOffset,
        double yOffset, RectangleEdge base, boolean pegShadow) {
    double x0 = bar.getMinX();
    double x1 = bar.getMaxX();
    double y0 = bar.getMinY();
    double y1 = bar.getMaxY();
    if (base == RectangleEdge.TOP) {
        x0 += xOffset;
        x1 += xOffset;
        if (!pegShadow) {
            y0 += yOffset;
        }
        y1 += yOffset;
    }
    else if (base == RectangleEdge.BOTTOM) {
        x0 += xOffset;
        x1 += xOffset;
        y0 += yOffset;
        if (!pegShadow) {
            y1 += yOffset;
        }
    }
    else if (base == RectangleEdge.LEFT) {
        if (!pegShadow) {
            x0 += xOffset;
        }
        x1 += xOffset;
        y0 += yOffset;
        y1 += yOffset;
    }
    else if (base == RectangleEdge.RIGHT) {
        x0 += xOffset;
        if (!pegShadow) {
            x1 += xOffset;
        }
        y0 += yOffset;
        y1 += yOffset;
    }
    return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0));
}
 
Example 15
Source File: LogAxis.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a list of ticks for an axis at the top or bottom of the chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param edge  the edge.
 *
 * @return A list of ticks.
 */
protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea,
        RectangleEdge edge) {

    Range range = getRange();
    List ticks = new ArrayList();
    Font tickLabelFont = getTickLabelFont();
    g2.setFont(tickLabelFont);
    TextAnchor textAnchor;
    if (edge == RectangleEdge.TOP) {
        textAnchor = TextAnchor.BOTTOM_CENTER;
    }
    else {
        textAnchor = TextAnchor.TOP_CENTER;
    }

    if (isAutoTickUnitSelection()) {
        selectAutoTickUnit(g2, dataArea, edge);
    }
    int minorTickCount = this.tickUnit.getMinorTickCount();
    double start = Math.floor(calculateLog(getLowerBound()));
    double end = Math.ceil(calculateLog(getUpperBound()));
    double current = start;
    while (current <= end) {
        double v = calculateValue(current);
        if (range.contains(v)) {
            ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v),
                    textAnchor, TextAnchor.CENTER, 0.0));
        }
        // add minor ticks (for gridlines)
        double next = Math.pow(this.base, current
                + this.tickUnit.getSize());
        for (int i = 1; i < minorTickCount; i++) {
            double minorV = v + i * ((next - v) / minorTickCount);
            if (range.contains(minorV)) {
                ticks.add(new NumberTick(TickType.MINOR, minorV, "",
                        textAnchor, TextAnchor.CENTER, 0.0));
            }
        }
        current = current + this.tickUnit.getSize();
    }
    return ticks;
}
 
Example 16
Source File: PeriodAxis.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the major and minor tick marks for an axis that lies at the top or 
 * bottom of the plot.
 * 
 * @param g2  the graphics device.
 * @param state  the axis state.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state, 
                                       Rectangle2D dataArea, 
                                       RectangleEdge edge) {
    List ticks = new ArrayList();
    double x0 = dataArea.getX();
    double y0 = state.getCursor();
    double insideLength = getTickMarkInsideLength();
    double outsideLength = getTickMarkOutsideLength();
    RegularTimePeriod t = RegularTimePeriod.createInstance(
            this.majorTickTimePeriodClass, this.first.getStart(), 
            getTimeZone());
    long t0 = t.getFirstMillisecond(this.calendar);
    Line2D inside = null;
    Line2D outside = null;
    long firstOnAxis = getFirst().getFirstMillisecond(this.calendar);
    long lastOnAxis = getLast().getLastMillisecond(this.calendar);
    while (t0 <= lastOnAxis) {
        ticks.add(new NumberTick(new Double(t0), "", TextAnchor.CENTER, 
                TextAnchor.CENTER, 0.0));
        x0 = valueToJava2D(t0, dataArea, edge);
        if (edge == RectangleEdge.TOP) {
            inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);  
            outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
        }
        if (t0 > firstOnAxis) {
            g2.setPaint(getTickMarkPaint());
            g2.setStroke(getTickMarkStroke());
            g2.draw(inside);
            g2.draw(outside);
        }
        // draw minor tick marks
        if (this.minorTickMarksVisible) {
            RegularTimePeriod tminor = RegularTimePeriod.createInstance(
                    this.minorTickTimePeriodClass, new Date(t0), 
                    getTimeZone());
            long tt0 = tminor.getFirstMillisecond(this.calendar);
            while (tt0 < t.getLastMillisecond(this.calendar) 
                    && tt0 < lastOnAxis) {
                double xx0 = valueToJava2D(tt0, dataArea, edge);
                if (edge == RectangleEdge.TOP) {
                    inside = new Line2D.Double(xx0, y0, xx0, 
                            y0 + this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0, 
                            y0 - this.minorTickMarkOutsideLength);
                }
                else if (edge == RectangleEdge.BOTTOM) {
                    inside = new Line2D.Double(xx0, y0, xx0, 
                            y0 - this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0, 
                            y0 + this.minorTickMarkOutsideLength);
                }
                if (tt0 >= firstOnAxis) {
                    g2.setPaint(this.minorTickMarkPaint);
                    g2.setStroke(this.minorTickMarkStroke);
                    g2.draw(inside);
                    g2.draw(outside);
                }
                tminor = tminor.next();
                tt0 = tminor.getFirstMillisecond(this.calendar);
            }
        }            
        t = t.next();
        t0 = t.getFirstMillisecond(this.calendar);
    }
    if (edge == RectangleEdge.TOP) {
        state.cursorUp(Math.max(outsideLength, 
                this.minorTickMarkOutsideLength));
    }
    else if (edge == RectangleEdge.BOTTOM) {
        state.cursorDown(Math.max(outsideLength, 
                this.minorTickMarkOutsideLength));
    }
    state.setTicks(ticks);
}
 
Example 17
Source File: CategoryAxis3D.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the axis on a Java 2D graphics device (such as the screen or a
 * printer).
 *
 * @param g2  the graphics device (<code>null</code> not permitted).
 * @param cursor  the cursor location.
 * @param plotArea  the area within which the axis should be drawn
 *                  (<code>null</code> not permitted).
 * @param dataArea  the area within which the plot is being drawn
 *                  (<code>null</code> not permitted).
 * @param edge  the location of the axis (<code>null</code> not permitted).
 * @param plotState  collects information about the plot (<code>null</code>
 *                   permitted).
 *
 * @return The axis state (never <code>null</code>).
 */
public AxisState draw(Graphics2D g2,
                      double cursor,
                      Rectangle2D plotArea,
                      Rectangle2D dataArea,
                      RectangleEdge edge,
                      PlotRenderingInfo plotState) {

    // if the axis is not visible, don't draw it...
    if (!isVisible()) {
        return new AxisState(cursor);
    }

    // calculate the adjusted data area taking into account the 3D effect...
    // this assumes that there is a 3D renderer, all this 3D effect is a
    // bit of an ugly hack...
    CategoryPlot plot = (CategoryPlot) getPlot();

    Rectangle2D adjustedDataArea = new Rectangle2D.Double();
    if (plot.getRenderer() instanceof Effect3D) {
        Effect3D e3D = (Effect3D) plot.getRenderer();
        double adjustedX = dataArea.getMinX();
        double adjustedY = dataArea.getMinY();
        double adjustedW = dataArea.getWidth() - e3D.getXOffset();
        double adjustedH = dataArea.getHeight() - e3D.getYOffset();

        if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
            adjustedY += e3D.getYOffset();
        }
        else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
            adjustedX += e3D.getXOffset();
        }
        adjustedDataArea.setRect(adjustedX, adjustedY, adjustedW,
                adjustedH);
    }
    else {
        adjustedDataArea.setRect(dataArea);
    }

    if (isAxisLineVisible()) {
        drawAxisLine(g2, cursor, adjustedDataArea, edge);
    }
    // draw the category labels and axis label
    AxisState state = new AxisState(cursor);
    if (isTickMarksVisible()) {
        drawTickMarks(g2, cursor, adjustedDataArea, edge, state);
    }
    state = drawCategoryLabels(g2, plotArea, adjustedDataArea, edge,
            state, plotState);
    state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state,
            plotState);

    return state;

}
 
Example 18
Source File: GradientXYBarPainter.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a shadow for the bar.
 *
 * @param bar  the bar shape.
 * @param xOffset  the x-offset for the shadow.
 * @param yOffset  the y-offset for the shadow.
 * @param base  the edge that is the base of the bar.
 * @param pegShadow  peg the shadow to the base?
 *
 * @return A rectangle for the shadow.
 */
private Rectangle2D createShadow(RectangularShape bar, double xOffset,
        double yOffset, RectangleEdge base, boolean pegShadow) {
    double x0 = bar.getMinX();
    double x1 = bar.getMaxX();
    double y0 = bar.getMinY();
    double y1 = bar.getMaxY();
    if (base == RectangleEdge.TOP) {
        x0 += xOffset;
        x1 += xOffset;
        if (!pegShadow) {
            y0 += yOffset;
        }
        y1 += yOffset;
    }
    else if (base == RectangleEdge.BOTTOM) {
        x0 += xOffset;
        x1 += xOffset;
        y0 += yOffset;
        if (!pegShadow) {
            y1 += yOffset;
        }
    }
    else if (base == RectangleEdge.LEFT) {
        if (!pegShadow) {
            x0 += xOffset;
        }
        x1 += xOffset;
        y0 += yOffset;
        y1 += yOffset;
    }
    else if (base == RectangleEdge.RIGHT) {
        x0 += xOffset;
        if (!pegShadow) {
            x1 += xOffset;
        }
        y0 += yOffset;
        y1 += yOffset;
    }
    return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0));
}
 
Example 19
Source File: NumberAxis.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Calculates the positions of the tick labels for the axis, storing the 
 * results in the tick label list (ready for drawing).
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data should be drawn.
 * @param edge  the location of the axis.
 * 
 * @return A list of ticks.
 */
protected List refreshTicksHorizontal(Graphics2D g2,
                                      Rectangle2D dataArea,
                                      RectangleEdge edge) {

    List result = new java.util.ArrayList();

    Font tickLabelFont = getTickLabelFont();
    g2.setFont(tickLabelFont);
    
    if (isAutoTickUnitSelection()) {
        selectAutoTickUnit(g2, dataArea, edge);
    }

    double size = getTickUnit().getSize();
    int count = calculateVisibleTickCount();
    double lowestTickValue = calculateLowestVisibleTickValue();

    if (count <= ValueAxis.MAXIMUM_TICK_COUNT) {
        for (int i = 0; i < count; i++) {
            double currentTickValue = lowestTickValue + (i * size);
            String tickLabel;
            NumberFormat formatter = getNumberFormatOverride();
            if (formatter != null) {
                tickLabel = formatter.format(currentTickValue);
            }
            else {
                tickLabel = getTickUnit().valueToString(currentTickValue);
            }
            TextAnchor anchor = null;
            TextAnchor rotationAnchor = null;
            double angle = 0.0;
            if (isVerticalTickLabels()) {
                anchor = TextAnchor.CENTER_RIGHT;
                rotationAnchor = TextAnchor.CENTER_RIGHT;
                if (edge == RectangleEdge.TOP) {
                    angle = Math.PI / 2.0;
                }
                else {
                    angle = -Math.PI / 2.0;
                }
            }
            else {
                if (edge == RectangleEdge.TOP) {
                    anchor = TextAnchor.BOTTOM_CENTER;
                    rotationAnchor = TextAnchor.BOTTOM_CENTER;
                }
                else {
                    anchor = TextAnchor.TOP_CENTER;
                    rotationAnchor = TextAnchor.TOP_CENTER;
                }
            }

            Tick tick = new NumberTick(new Double(currentTickValue), 
                    tickLabel, anchor, rotationAnchor, angle);
            result.add(tick);
        }
    }
    return result;

}
 
Example 20
Source File: GradientBarPainter.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a shadow for the bar.
 *
 * @param bar  the bar shape.
 * @param xOffset  the x-offset for the shadow.
 * @param yOffset  the y-offset for the shadow.
 * @param base  the edge that is the base of the bar.
 * @param pegShadow  peg the shadow to the base?
 *
 * @return A rectangle for the shadow.
 */
private Rectangle2D createShadow(RectangularShape bar, double xOffset,
        double yOffset, RectangleEdge base, boolean pegShadow) {
    double x0 = bar.getMinX();
    double x1 = bar.getMaxX();
    double y0 = bar.getMinY();
    double y1 = bar.getMaxY();
    if (base == RectangleEdge.TOP) {
        x0 += xOffset;
        x1 += xOffset;
        if (!pegShadow) {
            y0 += yOffset;
        }
        y1 += yOffset;
    }
    else if (base == RectangleEdge.BOTTOM) {
        x0 += xOffset;
        x1 += xOffset;
        y0 += yOffset;
        if (!pegShadow) {
            y1 += yOffset;
        }
    }
    else if (base == RectangleEdge.LEFT) {
        if (!pegShadow) {
            x0 += xOffset;
        }
        x1 += xOffset;
        y0 += yOffset;
        y1 += yOffset;
    }
    else if (base == RectangleEdge.RIGHT) {
        x0 += xOffset;
        if (!pegShadow) {
            x1 += xOffset;
        }
        y0 += yOffset;
        y1 += yOffset;
    }
    return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0));
}