Example usage for java.awt Graphics2D fillRect

List of usage examples for java.awt Graphics2D fillRect

Introduction

In this page you can find the example usage for java.awt Graphics2D fillRect.

Prototype

public abstract void fillRect(int x, int y, int width, int height);

Source Link

Document

Fills the specified rectangle.

Usage

From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java

/**
 *
 * @param xyz/*ww  w  .  j av a2 s .  c o  m*/
 * @param sl
 * @param spm
 * @param xybr
 * @param activeGraphics
 * @param dataArea
 * @param info
 * @param crosshairState
 * @return
 */
public BufferedImage prepareData(final XYZDataset xyz, final int sl, final int spm, final XYBlockRenderer xybr,
        Graphics2D activeGraphics, Rectangle2D dataArea, PlotRenderingInfo info,
        CrosshairState crosshairState) {
    long start = System.currentTimeMillis();
    final PaintScale ps = xybr.getPaintScale();
    double minz = Double.POSITIVE_INFINITY, maxz = Double.NEGATIVE_INFINITY;

    for (int i = 0; i < xyz.getSeriesCount(); i++) {
        final int items = xyz.getItemCount(i);
        for (int j = 0; j < items; j++) {
            minz = Math.min(xyz.getZValue(i, j), minz);
            maxz = Math.max(xyz.getZValue(i, j), maxz);
        }
    }
    if (ps instanceof GradientPaintScale) {
        ((GradientPaintScale) ps).setUpperBound(maxz);
        ((GradientPaintScale) ps).setLowerBound(minz);
    }
    Logger.getLogger(getClass().getName()).log(Level.INFO, "Finding min and max data took{0}ms",
            (System.currentTimeMillis() - start));

    //        VolatileImage bi = null;
    //        if (bi == null) {
    //        if (this.getOrientation() == PlotOrientation.VERTICAL) {
    BufferedImage bi = createCompatibleImage(sl, spm, BufferedImage.TRANSLUCENT);
    //        } else {
    //            bi = createCompatibleImage(spm, sl);
    //        }
    //        }else{
    //            img.validate(g.getDeviceConfiguration())
    //        }

    Graphics2D g2 = (Graphics2D) bi.getGraphics();
    g2.setColor((Color) ps.getPaint(ps.getLowerBound()));
    g2.fillRect(0, 0, sl, spm);
    // System.out.println("Using Threshold: " + threshold);
    int height = bi.getHeight();
    //final WritableRaster wr = bi.getRaster();
    XYItemRendererState xyrs = xybr.initialise(g2, dataArea, this, xyz, info);
    for (int i = 0; i < xyz.getSeriesCount(); i++) {
        final int items = xyz.getItemCount(i);
        for (int j = 0; j < items; j++) {
            final double tmp = xyz.getZValue(i, j);
            if (tmp > this.threshholdCutOff) {
                //if(j%50==0)System.out.println("Value > threshold: "+tmp);
                final Paint p = ps.getPaint(tmp);
                //                    final Paint tp = ps.getPaint(this.threshholdCutOff);
                //                    if (!tp.equals(p)) {
                if (p instanceof Color) {
                    final Color c = (Color) p;
                    g2.setColor(c);
                    //                    xybr.drawItem(g2, xyrs, dataArea, info, this, domainAxis, rangeAxis, xyz, i, j, crosshairState, 0);
                    //                        if (this.getOrientation() == PlotOrientation.VERTICAL) {

                    g2.fillRect((int) xyz.getXValue(i, j), height - (int) xyz.getYValue(i, j), 1, 1);
                    //                            wr.setPixel(, , new int[]{c.getRed(),
                    //                                        c.getGreen(), c.getBlue(), c.getAlpha()});
                    //                        } else {
                    //                            wr.setPixel((int) xyz.getYValue(i, j), (int) xyz.getXValue(i, j), new int[]{c.getRed(),
                    //                                        c.getGreen(), c.getBlue(), c.getAlpha()});
                    //                        }
                    //                }
                    //                    }
                }
            }
        }
    }

    Logger.getLogger(getClass().getName()).log(Level.INFO, "Creating image and drawing items took {0}ms",
            (System.currentTimeMillis() - start));

    return bi;
}

From source file:net.geoprism.dashboard.DashboardMap.java

/**
 * Builds an image layer of all the layers in a SavedMap.
 * //from   w  w  w. j a va 2s  .  co  m
 * @mapWidth
 * @mapHeight
 */
private BufferedImage getLegendExportCanvas(int mapWidth, int mapHeight) {
    int padding = 2;
    BufferedImage base = null;
    Graphics mapBaseGraphic = null;
    Color innerBackgroundColor = Color.darkGray;
    Color outerBorderColor = Color.black;
    int legendTopPlacement = 0;
    int legendLeftPlacement = 0;
    int widestLegend = 0;
    int legendXPosition = 0;
    int legendYPosition = 0;

    List<? extends DashboardLayer> layers = this.getAllHasLayer().getAll();

    try {
        base = new BufferedImage(mapWidth, mapHeight, BufferedImage.TYPE_INT_ARGB);
        mapBaseGraphic = base.getGraphics();
        mapBaseGraphic.drawImage(base, 0, 0, null);

        // Generates map overlays and combines them into a single map image
        for (DashboardLayer layer : layers) {
            if (layer.getDisplayInLegend()) {
                Graphics2D titleBaseGraphic = null;
                Graphics2D iconGraphic = null;

                String requestURL = getLegendURL(layer);

                try {
                    // handle color graphics and categories
                    BufferedImage titleBase = getLegendTitleImage(layer);
                    titleBaseGraphic = titleBase.createGraphics();
                    int paddedTitleWidth = titleBase.getWidth();
                    int paddedTitleHeight = titleBase.getHeight();

                    BufferedImage icon = getImageFromGeoserver(requestURL);
                    int iconHeight = icon.getHeight();
                    int iconWidth = icon.getWidth();
                    int paddedIconWidth = iconWidth + (padding * 2);
                    int paddedIconHeight = iconHeight + (padding * 2);

                    int fullWidth = paddedIconWidth + paddedTitleWidth;
                    int fullHeight;
                    if (paddedIconHeight >= paddedTitleHeight) {
                        fullHeight = paddedIconHeight;
                    } else {
                        fullHeight = paddedTitleHeight;
                    }

                    DashboardLegend legend = layer.getDashboardLegend();
                    if (legend.getGroupedInLegend()) {
                        if (legendTopPlacement + fullHeight >= mapHeight) {
                            legendLeftPlacement = widestLegend + legendLeftPlacement + padding;
                            legendTopPlacement = 0; // reset so 2nd column legends start at the top row
                        }
                        legendXPosition = legendLeftPlacement + padding;
                        legendYPosition = legendTopPlacement + padding;
                    } else {
                        legendXPosition = (int) Math.round((double) legend.getLegendXPosition());
                        legendYPosition = (int) Math.round((double) legend.getLegendYPosition());
                    }

                    BufferedImage legendBase = new BufferedImage(fullWidth + (padding * 2),
                            fullHeight + (padding * 2), BufferedImage.TYPE_INT_ARGB);
                    Graphics2D legendBaseGraphic = legendBase.createGraphics();
                    legendBaseGraphic.setColor(innerBackgroundColor);
                    legendBaseGraphic.fillRect(0, 0, fullWidth, fullHeight);
                    legendBaseGraphic.setColor(outerBorderColor);
                    legendBaseGraphic.setStroke(new BasicStroke(5));
                    legendBaseGraphic.drawRect(0, 0, fullWidth, fullHeight);

                    legendBaseGraphic.drawImage(icon, padding, padding, paddedIconWidth, paddedIconHeight,
                            null);
                    legendBaseGraphic.drawImage(titleBase, paddedIconWidth + (padding * 2),
                            (fullHeight / 2) - (paddedTitleHeight / 2), paddedTitleWidth, paddedTitleHeight,
                            null);
                    mapBaseGraphic.drawImage(legendBase, legendXPosition, legendYPosition, fullWidth,
                            fullHeight, null);

                    if (legend.getGroupedInLegend()) {
                        legendTopPlacement = legendTopPlacement + fullHeight + padding;
                    }

                    if (fullWidth > widestLegend) {
                        widestLegend = fullWidth;
                    }
                } finally {
                    if (titleBaseGraphic != null) {
                        titleBaseGraphic.dispose();
                    }

                    if (iconGraphic != null) {
                        iconGraphic.dispose();
                    }
                }
            }
        }
    } finally {
        mapBaseGraphic.dispose();
    }

    return base;
}

From source file:org.processmining.analysis.performance.advanceddottedchartanalysis.ui.DottedChartPanel.java

protected Graphics2D drawModelBuffer_Common(int imageWidth, int imageHeight, boolean isModel) {

    Graphics2D gBuf = null;
    if (isModel) {
        modelBuffer = new BufferedImage(Math.min(imageWidth, SCREENLENGTH), Math.min(imageHeight, SCREENLENGTH),
                BufferedImage.TYPE_INT_RGB);
        gBuf = modelBuffer.createGraphics();
    } else {//  ww  w.j a  va  2s  .  c  o m
        overviewBuffer = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
        gBuf = overviewBuffer.createGraphics();
    }

    gBuf.setColor(colorBg);
    gBuf.fillRect(0, 0, imageWidth, imageHeight);
    // draw background
    paintComponentLane(gBuf, imageWidth, imageHeight, isModel);
    if (isModel) {
        drawVerticalLines(gBuf, imageWidth, imageHeight);
    }
    // paint items
    initColorAndShapes();
    return gBuf;
}

From source file:com.codename1.android.AndroidLayoutImporter.java

private EncodedImage createBlankImage(String widthStr, String heightStr) {
    String name = "BlankImage";
    int width = convertToPixels(widthStr);
    if (width < 1)
        width = 1;/* w w  w  .  ja v a2 s.  co m*/
    int height = convertToPixels(heightStr);
    if (height < 1) {
        height = 1;
    }
    //System.out.println("Creating blank image "+width+"x"+height+" for "+widthStr+"x"+heightStr);
    String imgName = name + width + "x" + height + ".png";
    Image im = outputResources.getImage(imgName);
    if (im != null) {
        if (im instanceof EncodedImage) {
            return (EncodedImage) im;
        } else {
            return EncodedImage.createFromImage(im, false);
        }
    }
    BufferedImage center = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = (Graphics2D) center.createGraphics();
    //g2.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));
    g2.setColor(Color.red);
    g2.fillRect(0, 0, width, height);
    g2.dispose();

    EncodedImage placeholder = EncodedImage.create(toPng(center));

    EditableResources.MultiImage multiImage = new EditableResources.MultiImage();
    multiImage.setDpi(new int[] { Display.DENSITY_MEDIUM });
    multiImage.setInternalImages(new EncodedImage[] { placeholder });

    outputResources.setMultiImage(imgName, multiImage);
    return multiImage.getBest();
}

From source file:com.esri.ArcGISController.java

private void drawCells(final Graphics2D graphics, final int imageWidth, final int imageHeight,
        final double xmin, final double ymin, final double xdel, final double ydel, final Range range,
        final int[] ramp, final Set<Map.Entry<Long, Double>> set) {
    final int cellPixel = Math.max(1, (int) Math.ceil(imageWidth * m_cell / xdel));
    final int cellPixel2 = cellPixel / 2;

    final Color[] colors = new Color[256];

    for (final Map.Entry<Long, Double> entry : set) {
        final long key = entry.getKey();
        final double val = Math.min(range.hi, entry.getValue());

        if (val < range.lo) {
            continue;
        }//  w  ww. jav  a 2  s  .com

        final long cx = key & 0x7FFFL;
        final long cy = (key >> 16) & 0x7FFFL;
        final double wx = toWorld(cx, m_xofs, m_cell);
        final double wy = toWorld(cy, m_yofs, m_cell);
        final int px = toPixel(wx, imageWidth, xmin, xdel) - cellPixel2;
        final int py = imageHeight - toPixel(wy, imageHeight, ymin, ydel) - cellPixel2;

        final Color color = toColor(val, range, ramp, colors); // TODO - Create interface to handle zero range.dd

        graphics.setColor(color);
        graphics.fillRect(px, py, cellPixel, cellPixel);
    }

    // graphics.setColor(Color.RED);
    // graphics.drawRect(0, 0, imageWidth - 1, imageHeight - 1);
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.reporting.AnnotationReportCanvas.java

protected void paintComponent(Graphics g) {

    // prepare graphic object
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // set clipping area
    if (is_printing) {
        g2d.translate(-draw_area.x, -draw_area.y);
        g2d.setClip(draw_area);//from w  ww.j a v  a  2 s  . c  o m
    }

    //paint canvas background
    if (!is_printing) {
        g2d.setColor(getBackground());
        g2d.fillRect(0, 0, getWidth(), getHeight());
    }

    // paint white background on drawing area    
    g2d.setColor(Color.white);
    g2d.fillRect(draw_area.x, draw_area.y, draw_area.width, draw_area.height);
    if (!is_printing) {
        g2d.setColor(Color.black);
        g2d.draw(draw_area);
    }

    // paint
    paintChart(g2d);
    paintAnnotations(g2d);

    // dispose graphic object
    g2d.dispose();

    if (!is_printing) {
        if (first_time) {
            if (first_time_init_pos)
                placeStructures(true);
            else
                theDocument.fireDocumentInit();
            first_time = false;
        } else
            revalidate();
    }

}

From source file:org.viafirma.util.QRCodeUtil.java

/**
 * Genera codigo de firma para impresin formado por el texto, el cdigo qr
 * del texto y un cdigo de barras con el cdigo de firma.
 * //from w w w.j av a2s .  c om
 * @param text
 * @param codFirma
 * @return
 * @throws ExcepcionErrorInterno
 */
public byte[] generate(String text, String url, String textoQR, String codFirma) throws ExcepcionErrorInterno {
    // Comprobamos el tamao del texto. No recomendamos textos de mas de 120
    // caracteres
    if (textoQR.length() > MAX_TEXT_SIZE) {
        log.warn("El tamao del texto '" + text + "' ha excedido el tamao mximo. " + text.length() + ">"
                + MAX_TEXT_SIZE);
        textoQR = textoQR.substring(textoQR.lastIndexOf(" "));
        log.warn("El texto sera recortado: '" + textoQR + "'");
    }

    // Generamos la sufperficie de dibujo
    BufferedImage imagenQR = new BufferedImage(ANCHO_ETIQUETA, ALTO_ETIQUETA, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = imagenQR.createGraphics();
    // El fondo es blanco
    g.setBackground(Color.WHITE);
    g.clearRect(0, 0, ANCHO_ETIQUETA, ALTO_ETIQUETA);
    g.setColor(Color.BLACK);
    g.setStroke(new BasicStroke(2f));
    // Pintamos la caja de borde
    g.draw(new java.awt.Rectangle(MARGEN_CAJA, MARGEN_CAJA, ANCHO_ETIQUETA - MARGEN_CAJA * 2,
            ALTO_ETIQUETA - MARGEN_CAJA * 2));
    g.draw(new java.awt.Rectangle(MARGEN_CAJA + 3, MARGEN_CAJA + 3, ANCHO_ETIQUETA - MARGEN_CAJA * 2 - 6,
            ALTO_ETIQUETA - MARGEN_CAJA * 2 - 6));

    // Generamos el cdigo QR
    Qrcode x = new Qrcode();
    x.setQrcodeErrorCorrect('L');
    x.setQrcodeEncodeMode('B'); // Modo Binario
    byte[] d = textoQR.getBytes();
    // Generamos el cdigo QR
    boolean[][] s = x.calQrcode(d);
    for (int i = 0; i < s.length; i++) {
        for (int j = 0; j < s.length; j++) {
            if (s[j][i]) {
                g.fillRect(j * SIZE_QR + MARGEN, i * SIZE_QR + MARGEN, SIZE_QR, SIZE_QR);
            }
        }
    }
    int marjenSeparador = MARGEN + SIZE_QR * s.length + MARGEN_CAJA;
    int marjenTexto = marjenSeparador + MARGEN_CAJA;
    // Linea de separacin entre el QR cdigo y el texto
    g.drawLine(marjenSeparador - 3, MARGEN_CAJA + 3, marjenSeparador - 3, ALTO_ETIQUETA - MARGEN_CAJA - 3);
    g.drawLine(marjenSeparador, MARGEN_CAJA + 3, marjenSeparador, ALTO_ETIQUETA - MARGEN_CAJA - 3);

    // Linea de separacin entre texto y cdigo de barras.
    int marjenCodigoBarras = MARGEN + MAX_ROWS * FONT_SIZE;
    // Pintamos una pequea linea de separacin
    g.drawLine(marjenSeparador, marjenCodigoBarras, ANCHO_ETIQUETA - MARGEN_CAJA - 3, marjenCodigoBarras);
    g.drawLine(marjenSeparador, marjenCodigoBarras - 3, ANCHO_ETIQUETA - MARGEN_CAJA - 3,
            marjenCodigoBarras - 3);

    // Escribimos el texto
    List<String> parrafos = split(text);

    g.setFont(new Font(g.getFont().getName(), Font.BOLD, FONT_SIZE));

    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    for (int i = 0; i < parrafos.size(); i++) {
        String linea = parrafos.get(i);
        // Pintamos la nueva linea de texto
        g.drawString(linea, marjenTexto, MARGEN + 3 + (FONT_SIZE * i + 1));
    }

    g.setFont(new Font(g.getFont().getName(), Font.BOLD, FONT_SIZE - 4));
    // Pintamos el texto final de una sola lnea( Generalmente el MD5 )
    //if(url.length())
    if (!url.equals("")) {
        g.drawString("Custodia del documento: ", marjenTexto, marjenCodigoBarras - 10 * 2);
        g.drawString(url, marjenTexto, marjenCodigoBarras - 6);
    }
    marjenCodigoBarras += MARGEN_CAJA;
    // Generamos el cdigo de barras
    try {
        // int marjenCodigoBarras=MARGEN+MAX_ROWS*FONT_SIZE;
        BarcodeFactory.createCode39(codFirma, true).draw(g, marjenTexto, marjenCodigoBarras);
    } catch (Exception e1) { // TODO
        e1.printStackTrace();
    }
    // g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    // RenderingHints.VALUE_ANTIALIAS_OFF);

    // Finalizamos la superficie de dibujo
    g.dispose();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    // Generamos la imagen
    try {
        ImageIO.write(imagenQR, "png", out);
        // ImageIO.write(imagenQR, "png", new
        // FileOutputStream("/tmp/imagen.png"));
        out.close();
    } catch (Exception e) {
        throw new ExcepcionErrorInterno(CodigoError.ERROR_INTERNO, e);
    }

    return out.toByteArray();
}

From source file:com.openkm.module.direct.DirectWorkflowModule.java

@Override
public byte[] getProcessDefinitionImage(String token, long processDefinitionId, String node)
        throws RepositoryException, DatabaseException, WorkflowException {
    log.debug("getProcessDefinitionImage({}, {}, {})", new Object[] { token, processDefinitionId, node });
    JbpmContext jbpmContext = JBPMUtils.getConfig().createJbpmContext();
    byte[] image = null;
    Session session = null;//from   w  w  w .  java2s  .  c o m

    try {
        if (token == null) {
            session = JCRUtils.getSession();
        } else {
            session = JcrSessionManager.getInstance().get(token);
        }

        GraphSession graphSession = jbpmContext.getGraphSession();
        org.jbpm.graph.def.ProcessDefinition pd = graphSession.getProcessDefinition(processDefinitionId);
        FileDefinition fileDef = pd.getFileDefinition();

        WorkflowUtils.DiagramInfo dInfo = WorkflowUtils.getDiagramInfo(fileDef.getInputStream("gpd.xml"));
        WorkflowUtils.DiagramNodeInfo dNodeInfo = dInfo.getNodeMap().get(node);
        BufferedImage img = ImageIO.read(fileDef.getInputStream("processimage.jpg"));

        // Obtain all nodes Y
        List<Integer> ordenadas = new ArrayList<Integer>();

        for (WorkflowUtils.DiagramNodeInfo nodeInfo : dInfo.getNodeMap().values()) {
            ordenadas.add(nodeInfo.getY());
        }

        // Calculate minimal Y
        Collections.sort(ordenadas);
        int fix = ordenadas.get(0);

        if (dNodeInfo != null) {
            // Select node
            log.debug("DiagramNodeInfo: {}", dNodeInfo);
            Graphics g = img.getGraphics();
            Graphics2D g2d = (Graphics2D) g;
            g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25F));
            g2d.setColor(Color.blue);
            g2d.fillRect(dNodeInfo.getX(), dNodeInfo.getY() - fix, dNodeInfo.getWidth(), dNodeInfo.getHeight());
            g.dispose();
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(img, "jpg", baos);
        image = baos.toByteArray();
        baos.flush();
        baos.close();

        // Activity log
        UserActivity.log(session.getUserID(), "GET_PROCESS_DEFINITION_IMAGE", "" + processDefinitionId, null);
    } catch (javax.jcr.RepositoryException e) {
        throw new RepositoryException(e.getMessage(), e);
    } catch (JbpmException e) {
        throw new WorkflowException(e.getMessage(), e);
    } catch (IOException e) {
        throw new WorkflowException(e.getMessage(), e);
    } finally {
        if (token == null)
            JCRUtils.logout(session);
        jbpmContext.close();
    }

    log.debug("getProcessDefinitionImage: {}", image);
    return image;
}

From source file:org.trade.ui.chart.renderer.PivotRenderer.java

/**
 * Draws the visual representation of a single data item.
 * /*from www .j  a  v  a2s .c o  m*/
 * @param g2
 *            the graphics device.
 * @param state
 *            the renderer state.
 * @param dataArea
 *            the area within which the data is being drawn.
 * @param info
 *            collects information about the drawing.
 * @param plot
 *            the plot (can be used to obtain standard color information
 *            etc).
 * @param domainAxis
 *            the domain (horizontal) axis.
 * @param rangeAxis
 *            the range (vertical) axis.
 * @param dataset
 *            the dataset.
 * @param series
 *            the series index (zero-based).
 * @param item
 *            the item index (zero-based).
 * @param crosshairState
 *            crosshair information for the plot (<code>null</code>
 *            permitted).
 * @param pass
 *            the pass index.
 * @see org.jfree.chart.renderer.xy.XYItemRenderer#drawItem(Graphics2D,
 *      XYItemRendererState, Rectangle2D, PlotRenderingInfo, XYPlot,
 *      ValueAxis, ValueAxis, XYDataset, int, int, CrosshairState, int)
 */
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item,
        CrosshairState crosshairState, int pass) {

    // do nothing if item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }

    // get the data point...
    double x = dataset.getXValue(series, item);
    double y = dataset.getYValue(series, item);
    double adjx = (this.dotWidth - 1) / 2.0;
    double adjy = (this.dotHeight - 1) / 2.0;
    if (!Double.isNaN(y)) {
        RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
        RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
        double transX = domainAxis.valueToJava2D(x, dataArea, xAxisLocation) - adjx;
        double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation) - adjy;

        g2.setPaint(getItemPaint(series, item));
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            g2.fillRect((int) transY, (int) transX, this.dotHeight, this.dotWidth);
        } else if (orientation == PlotOrientation.VERTICAL) {
            g2.fillRect((int) transX, (int) transY, this.dotWidth, this.dotHeight);
        }

        int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
        int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
        updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY,
                orientation);

        PivotDataset pivotDataset = (PivotDataset) dataset;
        if (null != pivotDataset.getPivotSide(series, item)) {
            String ledgend = "Pivot";
            if (pivotDataset.getPivotSide(series, item).equals(Side.BOT)) {
                drawPivotArrow(g2, plot, dataArea, domainAxis, rangeAxis, item, info, 45d, x,
                        pivotDataset.getPivotValue(series, item), ledgend);
            } else {
                drawPivotArrow(g2, plot, dataArea, domainAxis, rangeAxis, item, info, -45d, x,
                        pivotDataset.getPivotValue(series, item), ledgend);
            }
        }
    }

}

From source file:org.prom5.analysis.performance.dottedchart.ui.DottedChartPanel.java

public void generateBufferedImage(int width, int height) {
    bDrawLine = dca.getSettingPanel().isDrawLine();
    matrixBuffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D gr = matrixBuffer.createGraphics();

    gr.setColor(colorBg);//from   www .  j  a v a  2 s .c o m
    gr.fillRect(0, 0, width, height);

    paintComponentLane(gr, width, height);

    // calculate are to be painted
    int unitHeight = height / getHashMapSize();
    int currentTop = 0;

    // paint items
    if (dcModel.getItemMap().size() > 0) {
        String key = null;
        AbstractLogUnit item = null;
        // iterate through sets
        int index = 0;
        for (Iterator itSets = dcModel.getSortedKeySetList().iterator(); itSets.hasNext();) {
            key = (String) itSets.next();
            // if key is not in instanceIDs, skip..
            if (dcModel.getTypeHashMap().equals(ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key))
                continue;

            currentTop = unit2Cord_buffer(index, height) + unitHeight / 2;

            LogUnitList tempUnitList = new LogUnitList();

            // iterate through items
            for (Iterator itItm = ((LogUnitList) dcModel.getItemMap().get(key)).iterator(); itItm.hasNext();) {
                item = (AbstractLogUnit) itItm.next();
                if (dcModel.getEventTypeToKeep() != null
                        && (!dcModel.getEventTypeToKeep().contains(item.getType()) || !dcModel
                                .getInstanceTypeToKeep().contains(item.getProcessInstance().getName())))
                    continue;
                // to do
                if (bDrawLine && item.getType().equals(dca.getSettingPanel().getStartEvent()))
                    tempUnitList.addEvent(item);
                assignColorByItem(item, gr);
                clipL = 0;
                clipR = width;

                double milli2pixels = (double) ((width) - 10)
                        / (double) (dcModel.getLogBoundaryRight().getTime()
                                - dcModel.getLogBoundaryLeft().getTime()); // + 2 is added to extend bound

                long clipLeftTs2 = coord2timeMillis_buffer(clipL, milli2pixels);
                long clipRightTs2 = coord2timeMillis_buffer(clipR, milli2pixels);
                // to do : if line is added
                if (bDrawLine && item.getType().equals(dca.getSettingPanel().getEndEvent())) {
                    for (Iterator itr = tempUnitList.iterator(); itr.hasNext();) {
                        AbstractLogUnit item2 = (AbstractLogUnit) itr.next();
                        if (item2.getElement().equals(item.getElement())
                                && item2.getProcessInstance().equals(item.getProcessInstance())) {
                            paintItemLine_buffer(
                                    time2coord_buffer(item2.getCurrentTimeStamp(), milli2pixels) + 3,
                                    currentTop, time2coord_buffer(item.getCurrentTimeStamp(), milli2pixels) + 3,
                                    gr);
                            tempUnitList.removeEvent(item2);
                            break;
                        }
                    }
                }

                // if item is not shown on the screen, skip drawing
                if (item.getCurrentTimeStamp().getTime() < clipLeftTs2
                        || item.getCurrentTimeStamp().getTime() > clipRightTs2)
                    continue;
                // paint an item
                this.paintItem_buffer(time2coord_buffer(item.getCurrentTimeStamp(), milli2pixels) + 3,
                        currentTop, gr, assignShapeByItem(item));

            }
            // move y point
            index++;
        }
    }
}