Example usage for java.awt.geom Rectangle2D getHeight

List of usage examples for java.awt.geom Rectangle2D getHeight

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D getHeight.

Prototype

public abstract double getHeight();

Source Link

Document

Returns the height of the framing rectangle in double precision.

Usage

From source file:de.iteratec.iteraplan.businesslogic.exchange.visio.informationflow.VisioInformationFlowExport.java

private void createNamesLegend(Rectangle2D legendsBox) throws MasterNotFoundException {
    double frameX = legendsBox.getX();
    double frameY = legendsBox.getY() - getTargetPage().getHeight() + MARGIN_IN;
    double frameWidth = legendsBox.getWidth();
    double frameHeight = getTargetPage().getHeight() - legendsBox.getHeight() - DISTANCE_TO_MARGIN_INCHES;
    createNamesLegend(frameX, frameY, frameWidth, frameHeight, informationFlowOptions.isNakedExport(),
            MessageAccess.getStringOrNull("graphicalExport.informationflow.title", getLocale()));
}

From source file:gov.nih.nci.caintegrator.application.graphing.BoxAndWhiskerDotsRenderer.java

/**
 * Initialises the renderer.  This method gets called once at the start of 
 * the process of drawing a chart.//from  w ww .  ja  v a  2  s.  co  m
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 *
 * @return The renderer state.
 */
public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot,
        int rendererIndex, PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info);

    // calculate the box width
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    if (dataset != null) {
        int columns = dataset.getColumnCount();
        int rows = dataset.getRowCount();
        double space = 0.0;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            space = dataArea.getHeight();
        } else if (orientation == PlotOrientation.VERTICAL) {
            space = dataArea.getWidth();
        }
        double categoryMargin = 0.0;
        double currentItemMargin = 0.0;
        if (columns > 1) {
            categoryMargin = domainAxis.getCategoryMargin();
        }
        if (rows > 1) {
            currentItemMargin = getItemMargin();
        }
        double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin
                - currentItemMargin);
        if ((rows * columns) > 0) {
            state.setBarWidth(used / (dataset.getColumnCount() * dataset.getRowCount()));
        } else {
            state.setBarWidth(used);
        }
    }

    if (state.getBarWidth() > maxBarWidth)
        state.setBarWidth(maxBarWidth);
    return state;

}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java

public void mouseDragged(MouseEvent e) {
    if (mouse_start_point != null && theDocument.getNoScans() > 0) {
        if (is_moving) {
            // moving
            double mz_delta = screenToDataX(mouse_start_point.getX() - e.getPoint().getX());
            if (mz_delta > 0.) {
                double old_upper_bound = thePlot.getDomainAxis().getUpperBound();
                double old_lower_bound = thePlot.getDomainAxis().getLowerBound();
                double new_upper_bound = Math.min(old_upper_bound + mz_delta,
                        theDocument.getPeakDataAt(current_ind).getMaxMZ());
                double new_lower_bound = old_lower_bound + new_upper_bound - old_upper_bound;

                thePlot.getDomainAxis().setRange(new Range(new_lower_bound, new_upper_bound));
            } else {
                double old_upper_bound = thePlot.getDomainAxis().getUpperBound();
                double old_lower_bound = thePlot.getDomainAxis().getLowerBound();
                double new_lower_bound = Math.max(old_lower_bound + mz_delta,
                        theDocument.getPeakDataAt(current_ind).getMinMZ());
                double new_upper_bound = old_upper_bound + new_lower_bound - old_lower_bound;

                thePlot.getDomainAxis().setRange(new Range(new_lower_bound, new_upper_bound));
            }/*from  w ww .j  a v  a 2 s  .c o  m*/

            mouse_start_point = e.getPoint();
        } else {
            // zooming                
            Graphics2D g2 = (Graphics2D) theChartPanel.getGraphics();
            g2.setXORMode(java.awt.Color.gray);

            // delete old rectangle
            if (zoom_rectangle != null)
                g2.draw(zoom_rectangle);

            // create new rectangle
            double start_x = Math.min(e.getX(), mouse_start_point.getX());
            double end_x = Math.max(e.getX(), mouse_start_point.getX());

            Rectangle2D data_area = theChartPanel.getScreenDataArea((int) start_x,
                    (int) mouse_start_point.getY());
            double xmax = Math.min(end_x, data_area.getMaxX());
            zoom_rectangle = new Rectangle2D.Double(start_x, data_area.getMinY(), xmax - start_x,
                    data_area.getHeight());

            // draw new rectangle
            g2.draw(zoom_rectangle);
            g2.dispose();
        }
    }
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.visio.informationflow.VisioInformationFlowExport.java

@Override
public Document createDiagram() {

    init();/*  w w  w  .  j  a v  a 2 s  . c om*/

    if (informationFlowOptions.isUseNamesLegend()) {
        setVisioNamesLegend(new VisioNamesLegend(this.getTargetPage()));
    }

    setColorDimension(createColorDimension(informationFlowOptions.getColorOptionsBean(),
            TypeOfBuildingBlock.INFORMATIONSYSTEMRELEASE));

    lineDimension = createLineDimension(informationFlowOptions.getLineOptionsBean(),
            TypeOfBuildingBlock.INFORMATIONSYSTEMRELEASE);

    lineCaptionSelected = informationFlowOptions.getSelectionType();
    lineCaptionAttributeId = informationFlowOptions.getLineCaptionSelectedAttributeId();

    addMissingParentNodes();
    addResultNodes();
    groupNodes();

    for (GXLNode node : GXLUtil.getNodes(graph)) {
        setIsrNodeTexts(node);
    }

    addEdges();

    try {
        LOGGER.debug("trying to add graph to gxl2visio converter");

        List<LayoutOperation> layoutOperations = determineLayoutOperations();

        Rectangle2D graphAreaBounds = visioDocumentCreator.addGraph(graph, layoutOperations);
        // correct the position of the bounding box, since it's returned incorrectly by the "addGraph"-method
        graphAreaBounds.setRect(0, 0, graphAreaBounds.getWidth(), graphAreaBounds.getHeight());

        Shape title = createDiagramTitle(
                MessageAccess.getStringOrNull("graphicalExport.informationflow.title", getLocale()));
        List<Shape> queryInfo = createQueryInfo(graphAreaBounds);

        Rectangle2D legendsBox = createLegends(graphAreaBounds);

        setTitlePos(graphAreaBounds, title, queryInfo);
        setQueryInfoPos(queryInfo, title.getPinX(), title.getPinY() - getQueryInfoHeight(queryInfo));

        Point2D adjustment = adjustPage(graphAreaBounds, title, queryInfo, legendsBox);
        legendsBox = new Rectangle2D.Double(legendsBox.getX() + adjustment.getX(),
                legendsBox.getY() + adjustment.getY(), legendsBox.getWidth(), legendsBox.getHeight());

        createGeneratedInformation(this.getTargetPage().getWidth());
        createLogos(0, 0, this.getTargetPage().getWidth(), this.getTargetPage().getHeight());

        if (informationFlowOptions.isUseNamesLegend()) {
            createNamesLegend(legendsBox);
        }

    } catch (GraphStructureException gex) {
        throw new IteraplanTechnicalException(IteraplanErrorMessages.INTERNAL_ERROR, gex);
    } catch (MasterNotFoundException e) {
        throw new IteraplanTechnicalException(IteraplanErrorMessages.INTERNAL_ERROR, e);
    }
    return visioDocumentCreator.getDocument();
}

From source file:savant.view.swing.GraphPane.java

/**
 * Render the background of this GraphPane
 *
 * @param g The graphics object to use/*www.  ja  v a  2 s  .  c  o m*/
 */
private void renderBackground(Graphics2D g2, boolean xGridOn, boolean yGridOn) {
    int h = getHeight();
    int w = getWidth();

    // Paint a gradient from top to bottom
    GradientPaint gp0 = new GradientPaint(0, 0, ColourSettings.getColor(ColourKey.GRAPH_PANE_BACKGROUND_TOP), 0,
            h, ColourSettings.getColor(ColourKey.GRAPH_PANE_BACKGROUND_BOTTOM));
    g2.setPaint(gp0);
    g2.fillRect(0, 0, w, h);

    // We don't want the axes stomping on our labels, so make sure the clip excludes them.
    Area clipArea = new Area(new Rectangle(0, 0, w, h));
    Color gridColor = ColourSettings.getColor(ColourKey.AXIS_GRID);

    if (yGridOn) {
        // Smallish font for tick labels.
        Font tickFont = g2.getFont().deriveFont(Font.PLAIN, 9);

        int[] yTicks = MiscUtils.getTickPositions(transformYPixel(getHeight()), transformYPixel(0.0));

        g2.setColor(gridColor);
        g2.setFont(tickFont);
        for (int t : yTicks) {
            double y = transformYPos(t);

            // Skip labels at the top or bottom of the window because they look stupid.
            if (y != 0.0 && y != getHeight()) {
                String s = Integer.toString(t);
                Rectangle2D labelRect = tickFont.getStringBounds(s, g2.getFontRenderContext());
                double baseline = y + labelRect.getHeight() * 0.5 - 2.0;
                g2.drawString(s, 4.0F, (float) baseline);
                clipArea.subtract(new Area(new Rectangle2D.Double(3.0, baseline - labelRect.getHeight() - 1.0,
                        labelRect.getWidth() + 2.0, labelRect.getHeight() + 2.0)));
            }
        }
        g2.setClip(clipArea);
        for (int t2 : yTicks) {
            double y = transformYPos(t2);
            g2.draw(new Line2D.Double(0.0, y, w, y));
        }
    }
    if (xGridOn) {
        Range r = LocationController.getInstance().getRange();
        int[] xTicks = MiscUtils.getTickPositions(r);

        g2.setColor(gridColor);
        for (int t : xTicks) {
            double x = transformXPos(t);
            g2.draw(new Line2D.Double(x, 0, x, h));
        }
    }
    g2.setClip(null);
}

From source file:org.caleydo.view.domino.internal.Block.java

/**
 * @param r/*from   ww  w  .j  a v a2  s  . c  o  m*/
 */
public void selectByBounds(Rectangle2D r, EToolState tool) {
    r = (Rectangle2D) r.clone(); // local copy

    Vec2f l = getLocation(); // to relative coordinates;
    r = new Rectangle2D.Double(r.getX() - l.x(), r.getY() - l.y(), r.getWidth(), r.getHeight());
    if (tool == EToolState.BANDS) {
        if (getOutlineShape().intersects(r)) {
            selectMe();
            repaint();
        }
    } else {
        for (Node node : nodes()) {
            if (node.getRectangleBounds().intersects(r)) {
                node.selectByBounds(r);
            }
        }
    }
}

From source file:org.apache.fop.render.intermediate.IFRenderer.java

/** {@inheritDoc} */
protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) {
    Rectangle posInt = new Rectangle(currentIPPosition + (int) pos.getX(), currentBPPosition + (int) pos.getY(),
            (int) pos.getWidth(), (int) pos.getHeight());
    uri = URISpecification.getURL(uri);/*from  w w w .  jav  a2 s. c o  m*/
    try {
        establishForeignAttributes(foreignAttributes);
        painter.drawImage(uri, posInt);
        resetForeignAttributes();
    } catch (IFException ife) {
        handleIFException(ife);
    }
}

From source file:KIDLYRenderer.java

/**
 * Calculates the coordinate of the first "side" of a bar.  This will be
 * the minimum x-coordinate for a vertical bar, and the minimum
 * y-coordinate for a horizontal bar.// ww  w.  j  a v a  2  s .  co m
 *
 * @param plot  the plot.
 * @param orientation  the plot orientation.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param state  the renderer state (has the bar width precalculated).
 * @param row  the row index.
 * @param column  the column index.
 *
 * @return The coordinate.
 */
protected double calculateBarW0(CategoryPlot plot, PlotOrientation orientation, Rectangle2D dataArea,
        CategoryAxis domainAxis, CategoryItemRendererState state, int row, int column) {
    // calculate bar width...
    double space = 0.0;
    if (orientation == PlotOrientation.HORIZONTAL) {
        space = dataArea.getHeight();
    } else {
        space = dataArea.getWidth();
    }
    double barW0 = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge());
    int seriesCount = state.getVisibleSeriesCount() >= 0 ? state.getVisibleSeriesCount() : getRowCount();
    int categoryCount = getColumnCount();
    if (seriesCount > 1) {
        double seriesGap = space * getItemMargin() / (categoryCount * (seriesCount - 1));
        double seriesW = calculateSeriesWidth(space, domainAxis, categoryCount, seriesCount);
        barW0 = barW0 + row * (seriesW + seriesGap) + (seriesW / 2.0) - (state.getBarWidth() / 2.0);
    } else {
        barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge())
                - state.getBarWidth() / 2.0;
    }
    return barW0;
}

From source file:org.apache.fop.render.intermediate.IFRenderer.java

/** {@inheritDoc} */
public void renderForeignObject(ForeignObject fo, Rectangle2D pos) {
    endTextObject();//  w w  w  .  j  a va2  s . c om
    Rectangle posInt = new Rectangle(currentIPPosition + (int) pos.getX(), currentBPPosition + (int) pos.getY(),
            (int) pos.getWidth(), (int) pos.getHeight());
    Document doc = fo.getDocument();
    try {
        establishForeignAttributes(fo.getForeignAttributes());
        painter.drawImage(doc, posInt);
        resetForeignAttributes();
    } catch (IFException ife) {
        handleIFException(ife);
    }
}

From source file:edu.dlnu.liuwenpeng.render.BarRenderer.java

/**    
* Calculates the bar width and stores it in the renderer state.    
*    /*from  ww w  .ja  va 2  s  .com*/
* @param plot  the plot.    
* @param dataArea  the data area.    
* @param rendererIndex  the renderer index.    
* @param state  the renderer state.    
*/
protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex,
        CategoryItemRendererState state) {

    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    if (dataset != null) {
        int columns = dataset.getColumnCount();
        int rows = dataset.getRowCount();
        double space = 0.0;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            space = dataArea.getHeight();
        } else if (orientation == PlotOrientation.VERTICAL) {
            space = dataArea.getWidth();
        }
        double maxWidth = space * getMaximumBarWidth();
        double categoryMargin = 0.0;
        double currentItemMargin = 0.0;
        if (columns > 1) {
            categoryMargin = domainAxis.getCategoryMargin();
        }
        if (rows > 1) {
            currentItemMargin = getItemMargin();
        }
        double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin
                - currentItemMargin);
        if ((rows * columns) > 0) {
            state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
        } else {
            state.setBarWidth(Math.min(used, maxWidth));
        }
    }
}