当前位置: 首页>>代码示例>>Java>>正文


Java RectangleEdge类代码示例

本文整理汇总了Java中org.jfree.ui.RectangleEdge的典型用法代码示例。如果您正苦于以下问题:Java RectangleEdge类的具体用法?Java RectangleEdge怎么用?Java RectangleEdge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RectangleEdge类属于org.jfree.ui包,在下文中一共展示了RectangleEdge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateAnchorPoint

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Calculates the anchor point for a tick label.
 * 
 * @param tick  the tick.
 * @param cursor  the cursor.
 * @param dataArea  the data area.
 * @param edge  the edge on which the axis is drawn.
 * 
 * @return The x and y coordinates of the anchor point.
 */
protected float[] calculateAnchorPoint(ValueTick tick, 
                                       double cursor, 
                                       Rectangle2D dataArea, 
                                       RectangleEdge edge) {

    RectangleInsets insets = getTickLabelInsets();
    float[] result = new float[2];
    if (edge == RectangleEdge.TOP) {
        result[0] = (float) valueToJava2D(tick.getValue(), dataArea, edge);
        result[1] = (float) (cursor - insets.getBottom() - 2.0);
    }
    else if (edge == RectangleEdge.BOTTOM) {
        result[0] = (float) valueToJava2D(tick.getValue(), dataArea, edge);
        result[1] = (float) (cursor + insets.getTop() + 2.0); 
    }
    else if (edge == RectangleEdge.LEFT) {
        result[0] = (float) (cursor - insets.getLeft() - 2.0);    
        result[1] = (float) valueToJava2D(tick.getValue(), dataArea, edge);
    }
    else if (edge == RectangleEdge.RIGHT) {
        result[0] = (float) (cursor + insets.getRight() + 2.0);    
        result[1] = (float) valueToJava2D(tick.getValue(), dataArea, edge);
    }
    return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:36,代码来源:ValueAxis.java

示例2: drawRangeCrosshair

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Draws a range crosshair.
 * 
 * @param g2  the graphics target.
 * @param dataArea  the data area.
 * @param orientation  the plot orientation.
 * @param value  the crosshair value.
 * @param axis  the axis against which the value is measured.
 * @param stroke  the stroke used to draw the crosshair line.
 * @param paint  the paint used to draw the crosshair line.
 * 
 * @since 1.0.4
 */
protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, 
        PlotOrientation orientation, double value, ValueAxis axis, 
        Stroke stroke, Paint paint) {
    
    if (axis.getRange().contains(value)) {
        Line2D line = null;
        if (orientation == PlotOrientation.HORIZONTAL) {
            double xx = axis.valueToJava2D(value, dataArea, 
                    RectangleEdge.BOTTOM);
            line = new Line2D.Double(xx, dataArea.getMinY(), xx, 
                    dataArea.getMaxY());
        }
        else {
            double yy = axis.valueToJava2D(value, dataArea, 
                    RectangleEdge.LEFT);
            line = new Line2D.Double(dataArea.getMinX(), yy, 
                    dataArea.getMaxX(), yy);
        }
        g2.setStroke(stroke);
        g2.setPaint(paint);
        g2.draw(line);
    }
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:38,代码来源:XYPlot.java

示例3: getLabelEnclosure

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Returns a rectangle that encloses the axis label.  This is typically 
 * used for layout purposes (it gives the maximum dimensions of the label).
 *
 * @param g2  the graphics device.
 * @param edge  the edge of the plot area along which the axis is measuring.
 *
 * @return The enclosing rectangle.
 */
protected Rectangle2D getLabelEnclosure(Graphics2D g2, RectangleEdge edge) {

    Rectangle2D result = new Rectangle2D.Double();
    String axisLabel = getLabel();
    if (axisLabel != null && !axisLabel.equals("")) {
        FontMetrics fm = g2.getFontMetrics(getLabelFont());
        Rectangle2D bounds = TextUtilities.getTextBounds(axisLabel, g2, fm);
        RectangleInsets insets = getLabelInsets();
        bounds = insets.createOutsetRectangle(bounds);
        double angle = getLabelAngle();
        if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) {
            angle = angle - Math.PI / 2.0;
        }
        double x = bounds.getCenterX();
        double y = bounds.getCenterY();
        AffineTransform transformer 
            = AffineTransform.getRotateInstance(angle, x, y);
        Shape labelBounds = transformer.createTransformedShape(bounds);
        result = labelBounds.getBounds2D();
    }

    return result;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:34,代码来源:Axis.java

示例4: calculateAnchorPoint

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Calculates the anchor point for a tick.
 * 
 * @param tick  the tick.
 * @param cursor  the cursor.
 * @param dataArea  the data area.
 * @param edge  the side on which the axis is displayed.
 * 
 * @return The anchor point.
 */
protected float[] calculateAnchorPoint(ValueTick tick, double cursor, 
                                       Rectangle2D dataArea, 
                                       RectangleEdge edge) {
    if (tick instanceof CycleBoundTick) {
        boolean mapsav = this.boundMappedToLastCycle;
        this.boundMappedToLastCycle 
            = ((CycleBoundTick) tick).mapToLastCycle;
        float[] ret = super.calculateAnchorPoint(
            tick, cursor, dataArea, edge
        );
        this.boundMappedToLastCycle = mapsav;
        return ret;
    }
    return super.calculateAnchorPoint(tick, cursor, dataArea, edge);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:CyclicNumberAxis.java

示例5: draw

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * 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 (determines where to draw the axis).
 * @param plotArea  the area within which the axes and plot should be drawn.
 * @param dataArea  the area within which the data should be drawn.
 * @param edge  the axis location (<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) {
    
    AxisState axisState = new AxisState(cursor);
    if (isAxisLineVisible()) {
        drawAxisLine(g2, cursor, dataArea, edge);
    }
    drawTickMarks(g2, axisState, dataArea, edge);
    for (int band = 0; band < this.labelInfo.length; band++) {
        axisState = drawTickLabels(band, g2, axisState, dataArea, edge);
    }
    
    // draw the axis label (note that 'state' is passed in *and* 
    // returned)...
    axisState = drawLabel(getLabel(), g2, plotArea, dataArea, edge, 
            axisState);
    return axisState;
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:38,代码来源:PeriodAxis.java

示例6: drawAxisLine

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * 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);
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:34,代码来源:Axis.java

示例7: calculateCategoryGapSize

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Calculates the size (width or height, depending on the location of the axis) of a category
 * gap.
 *
 * @param categoryCount  the number of categories.
 * @param area  the area within which the categories will be drawn.
 * @param edge  the axis location.
 *
 * @return the category gap width.
 */
protected double calculateCategoryGapSize(int categoryCount, Rectangle2D area,
                                          RectangleEdge edge) {

    double result = 0.0;
    double available = 0.0;

    if ((edge == RectangleEdge.TOP) || (edge == RectangleEdge.BOTTOM)) {
        available = area.getWidth();
    }
    else if ((edge == RectangleEdge.LEFT) || (edge == RectangleEdge.RIGHT)) {
        available = area.getHeight();
    }

    if (categoryCount > 1) {
        result = available * getCategoryMargin() / (categoryCount - 1);
    }

    return result;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:CategoryAxis.java

示例8: TextTitle

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Creates a new title.
 *
 * @param text  the text for the title (<code>null</code> not permitted).
 * @param font  the title font (<code>null</code> not permitted).
 * @param paint  the title paint (<code>null</code> not permitted).
 * @param position  the title position (<code>null</code> not permitted).
 * @param horizontalAlignment  the horizontal alignment (<code>null</code> not permitted).
 * @param verticalAlignment  the vertical alignment (<code>null</code> not permitted).
 * @param spacer  the space to leave around the outside of the title.
 */
public TextTitle(String text, 
                 Font font, 
                 Paint paint, 
                 RectangleEdge position,
                 HorizontalAlignment horizontalAlignment, 
                 VerticalAlignment verticalAlignment,
                 Spacer spacer) {

    super(position, horizontalAlignment, verticalAlignment, spacer);
    
    if (text == null) {
        throw new NullPointerException("Null 'text' argument.");
    }
    if (font == null) {
        throw new NullPointerException("Null 'font' argument.");
    }
    if (paint == null) {
        throw new NullPointerException("Null 'paint' argument.");
    }
    this.text = text;
    this.font = font;
    this.paint = paint;
    this.backgroundPaint = null;
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:37,代码来源:TextTitle.java

示例9: draw

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Draws the title on a Java 2D graphics device (such as the screen or a printer).
 *
 * @param g2  the graphics device.
 * @param area  the area allocated for the title.
 */
public void draw(Graphics2D g2, Rectangle2D area) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Drawing title to area " + area.toString());
    }
    if (this.text.equals("")) {
        return;
    }
    if (this.backgroundPaint != null) {
        g2.setPaint(this.backgroundPaint);
        g2.fill(area);
    }
    RectangleEdge position = getPosition();
    if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) {
        drawHorizontal(g2, area);
    }
    else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) {
        drawVertical(g2, area);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:TextTitle.java

示例10: calculateAnchorPoint

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Calculates the anchor point for a tick label.
 * 
 * @param tick  the tick.
 * @param cursor  the cursor.
 * @param dataArea  the data area.
 * @param edge  the edge on which the axis is drawn.
 * 
 * @return  the x and y coordinates of the anchor point.
 */
protected float[] calculateAnchorPoint(ValueTick tick, 
                                       double cursor, 
                                       Rectangle2D dataArea, 
                                       RectangleEdge edge) {

    float[] result = new float[2];
    if (edge == RectangleEdge.TOP) {
        result[0] = (float) this.valueToJava2D(tick.getValue(), dataArea, edge);
        result[1] = (float) (cursor - getTickLabelInsets().bottom - 2.0);    
    }
    else if (edge == RectangleEdge.BOTTOM) {
        result[0] = (float) this.valueToJava2D(tick.getValue(), dataArea, edge);
        result[1] = (float) (cursor + getTickLabelInsets().top + 2.0);                
    }
    else if (edge == RectangleEdge.LEFT) {
        result[0] = (float) (cursor - getTickLabelInsets().left - 2.0);    
        result[1] = (float) this.valueToJava2D(tick.getValue(), dataArea, edge);
    }
    else if (edge == RectangleEdge.RIGHT) {
        result[0] = (float) (cursor + getTickLabelInsets().right + 2.0);    
        result[1] = (float) this.valueToJava2D(tick.getValue(), dataArea, edge);
    }
    return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:ValueAxis.java

示例11: testJava2DToValue

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Test the translation of Java2D values to data values.
 */
public void testJava2DToValue() {
    DateAxis axis = new DateAxis();
    axis.setRange(50.0, 100.0); 
    Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0);
    double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);  
    assertTrue(same(y1, 95.8333333, 1.0)); 
    double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);   
    assertTrue(same(y2, 95.8333333, 1.0)); 
    double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);   
    assertTrue(same(x1, 58.125, 1.0)); 
    double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);   
    assertTrue(same(x2, 58.125, 1.0)); 
    axis.setInverted(true);
    double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);  
    assertTrue(same(y3, 54.1666667, 1.0)); 
    double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);   
    assertTrue(same(y4, 54.1666667, 1.0)); 
    double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);   
    assertTrue(same(x3, 91.875, 1.0)); 
    double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);   
    assertTrue(same(x4, 91.875, 1.0));   
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:DateAxisTests.java

示例12: draw

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Draws the annotation.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param rendererIndex  the renderer index.
 * @param info  if supplied, this info object will be populated with
 *              entity information.
 */
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
                 ValueAxis domainAxis, ValueAxis rangeAxis, 
                 int rendererIndex,
                 PlotRenderingInfo info) {

    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
            plot.getDomainAxisLocation(), orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
            plot.getRangeAxisLocation(), orientation);
    float j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea, 
            domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea, 
            rangeEdge);
    Rectangle2D area = new Rectangle2D.Double(j2DX - this.width / 2.0, 
            j2DY - this.height / 2.0, this.width, this.height);
    this.drawable.draw(g2, area);
    String toolTip = getToolTipText();
    String url = getURL();
    if (toolTip != null || url != null) {
        addEntity(info, area, rendererIndex, toolTip, url);
    }
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:37,代码来源:XYDrawableAnnotation.java

示例13: handleClick

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Handles a 'click' on the plot by updating the anchor value.
 *
 * @param x  x-coordinate of the click (in Java2D space).
 * @param y  y-coordinate of the click (in Java2D space).
 * @param info  information about the plot's dimensions.
 *
 */
public void handleClick(int x, int y, PlotRenderingInfo info) {

    Rectangle2D dataArea = info.getDataArea();
    if (dataArea.contains(x, y)) {
        // set the anchor value for the range axis...
        double java2D = 0.0;
        if (this.orientation == PlotOrientation.HORIZONTAL) {
            java2D = x;
        }
        else if (this.orientation == PlotOrientation.VERTICAL) {
            java2D = y;
        }
        RectangleEdge edge = Plot.resolveRangeAxisLocation(
                getRangeAxisLocation(), this.orientation);
        double value = getRangeAxis().java2DToValue(
                java2D, info.getDataArea(), edge);
        setAnchorValue(value);
        setRangeCrosshairValue(value);
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:CategoryPlot.java

示例14: refreshTicks

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * 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 state  the axis state.
 * @param plotArea  the area in which the plot (inlcuding axes) should be drawn.
 * @param dataArea  the area in which the data should be drawn.
 * @param edge  the location of the axis.
 * 
 * @return A list of ticks.
 */
public List refreshTicks(Graphics2D g2, 
                         AxisState state,
                         Rectangle2D plotArea, 
                         Rectangle2D dataArea,
                         RectangleEdge edge) {

    List ticks = null;
    if (RectangleEdge.isTopOrBottom(edge)) {
        ticks = refreshTicksHorizontal(g2, state.getCursor(), plotArea, dataArea, edge);
    }
    else if (RectangleEdge.isLeftOrRight(edge)) {
        ticks = refreshTicksVertical(g2, state.getCursor(), plotArea, dataArea, edge);
    }
    return ticks;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:SymbolicAxis.java

示例15: getCategoryJava2DCoordinate

import org.jfree.ui.RectangleEdge; //导入依赖的package包/类
/**
 * Returns the Java 2D coordinate for a category.
 * 
 * @param anchor  the anchor point.
 * @param category  the category index.
 * @param categoryCount  the category count.
 * @param area  the data area.
 * @param edge  the location of the axis.
 * 
 * @return the coordinate.
 */
public double getCategoryJava2DCoordinate(CategoryAnchor anchor, 
                                          int category, 
                                          int categoryCount, 
                                          Rectangle2D area,
                                          RectangleEdge edge) {

    double result = 0.0;
    if (anchor == CategoryAnchor.START) {
        result = getCategoryStart(category, categoryCount, area, edge);
    }
    else if (anchor == CategoryAnchor.MIDDLE) {
        result = getCategoryMiddle(category, categoryCount, area, edge);
    }
    else if (anchor == CategoryAnchor.END) {
        result = getCategoryEnd(category, categoryCount, area, edge);
    }
    return result;
                                                  
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:CategoryAxis.java


注:本文中的org.jfree.ui.RectangleEdge类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。