List of usage examples for java.awt Color gray
Color gray
To view the source code for java.awt Color gray.
Click Source Link
From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java
/** * //from w ww . j a v a2s .c o m * @param applet * @param container */ public static void updateDisplay(final JApplet applet, final Container container) { if (container != null) { final PanelBuilder builder = createBuilder(new String[] { "5dlu", "fill:default:grow", "5dlu" }, new String[] { "5dlu", "fill:default:grow", "5dlu" }); final CellConstraints cc = new CellConstraints(); builder.add(container, cc.xy(2, 2)); final JPanel panel = createPanel(builder); panel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.GRAY)); applet.getContentPane().removeAll(); applet.getContentPane().add(panel); applet.getContentPane().validate(); applet.getContentPane().repaint(); } }
From source file:cool.pandora.modeller.ui.jpanel.base.BagView.java
/** * createBagPanel./*from w ww. j a va 2 s . com*/ * * @return splitPane */ private JSplitPane createBagPanel() { final LineBorder border = new LineBorder(Color.GRAY, 1); bagButtonPanel = createBagButtonPanel(); final JPanel bagTagButtonPanel = createBagTagButtonPanel(); bagPayloadTree = new BagTree(this, AbstractBagConstants.DATA_DIRECTORY); bagPayloadTree.setEnabled(false); bagPayloadTreePanel = new BagTreePanel(bagPayloadTree); bagPayloadTreePanel.setEnabled(false); bagPayloadTreePanel.setBorder(border); bagPayloadTreePanel.setToolTipText(getMessage("bagTree.help")); bagTagFileTree = new BagTree(this, getMessage("bag.label.noname")); bagTagFileTree.setEnabled(false); bagTagFileTreePanel = new BagTreePanel(bagTagFileTree); bagTagFileTreePanel.setEnabled(false); bagTagFileTreePanel.setBorder(border); bagTagFileTreePanel.setToolTipText(getMessage("bagTree.help")); tagManifestPane = new TagManifestPane(this); tagManifestPane.setToolTipText(getMessage("compositePane.tab.help")); final JSplitPane splitPane = new JSplitPane(); splitPane.setResizeWeight(0.5); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); final JPanel payloadPannel = new JPanel(); splitPane.setLeftComponent(payloadPannel); payloadPannel.setLayout(new BorderLayout(0, 0)); final JPanel payLoadToolBarPanel = new JPanel(); payloadPannel.add(payLoadToolBarPanel, BorderLayout.NORTH); payLoadToolBarPanel.setLayout(new GridLayout(1, 0, 0, 0)); final JPanel payloadLabelPanel = new JPanel(); final FlowLayout flowLayout = (FlowLayout) payloadLabelPanel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); payLoadToolBarPanel.add(payloadLabelPanel); final JLabel lblPayloadTree = new JLabel(getMessage("bagView.payloadTree.name")); payloadLabelPanel.add(lblPayloadTree); payLoadToolBarPanel.add(bagButtonPanel); payloadPannel.add(bagPayloadTreePanel, BorderLayout.CENTER); final JPanel tagFilePanel = new JPanel(); splitPane.setRightComponent(tagFilePanel); tagFilePanel.setLayout(new BorderLayout(0, 0)); final JPanel tagFileToolBarPannel = new JPanel(); tagFilePanel.add(tagFileToolBarPannel, BorderLayout.NORTH); tagFileToolBarPannel.setLayout(new GridLayout(0, 2, 0, 0)); final JPanel TagFileLabelPanel = new JPanel(); final FlowLayout tagFileToolbarFlowLayout = (FlowLayout) TagFileLabelPanel.getLayout(); tagFileToolbarFlowLayout.setAlignment(FlowLayout.LEFT); tagFileToolBarPannel.add(TagFileLabelPanel); final JLabel tagFileTreeLabel = new JLabel(getMessage("bagView.TagFilesTree.name")); TagFileLabelPanel.add(tagFileTreeLabel); tagFileToolBarPannel.add(bagTagButtonPanel); tagFilePanel.add(bagTagFileTreePanel, BorderLayout.CENTER); return splitPane; }
From source file:mil.tatrc.physiology.utilities.csv.plots.MultiPlotter.java
protected void formatMultiPlot(PlotJob job, JFreeChart chart, XYSeriesCollection dataSet1, XYSeriesCollection dataSet2) {//from w w w . j a v a2 s. co m Color[] blueColors = { Color.blue, Color.cyan, new Color(0, 160, 255), new Color(0, 100, 255), new Color(0, 160, 255), new Color(14, 0, 145), new Color(70, 105, 150) }; Color[] redColors = { Color.red, Color.magenta, new Color(255, 0, 100), new Color(255, 0, 160), Color.pink, new Color(145, 0, 0), new Color(132, 58, 58) }; Color[] variedColors = { Color.red, Color.blue, Color.green, Color.orange, Color.magenta, Color.cyan, Color.gray, new Color(255, 165, 0), new Color(42, 183, 136), new Color(87, 158, 186) }; XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) plot.getRenderer(); BasicStroke wideLine = new BasicStroke(2.0f); //For Scientific notation NumberFormat formatter = new DecimalFormat("0.######E0"); for (int i = 0; i < plot.getDomainAxisCount(); i++) { plot.getDomainAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize)); plot.getDomainAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15)); plot.getDomainAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black); plot.getDomainAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black); } for (int i = 0; i < plot.getRangeAxisCount(); i++) { plot.getRangeAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize)); plot.getRangeAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15)); plot.getRangeAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black); plot.getRangeAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(i); rangeAxis.setNumberFormatOverride(formatter); } //White background outside of plottable area chart.setBackgroundPaint(job.bgColor); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 15)); chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, job.fontSize)); chart.getTitle().setPaint(job.bgColor == Color.red ? Color.white : Color.black); //If there is only one Y axis, we just need to color the data series differently if (job.Y2headers == null || job.Y2headers.isEmpty()) { for (int i = 0, cIndex = 0; i < dataSet1.getSeriesCount(); i++, cIndex++) { renderer1.setSeriesStroke(i, wideLine); renderer1.setBaseShapesVisible(false); if (cIndex > 9) cIndex = 0; renderer1.setSeriesFillPaint(i, variedColors[cIndex]); renderer1.setSeriesPaint(i, variedColors[cIndex]); } } //If there are 2 Y axes, we should color the axes to correspond with the data so it isn't (as) confusing else { StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); plot.setRenderer(1, renderer2); for (int i = 0, cIndex = 0; i < dataSet1.getSeriesCount(); i++, cIndex++) { renderer1.setSeriesStroke(i, wideLine); renderer1.setBaseShapesVisible(false); if (cIndex > 6) cIndex = 0; renderer1.setSeriesFillPaint(i, redColors[cIndex]); renderer1.setSeriesPaint(i, redColors[cIndex]); } for (int i = 0, cIndex = 0; i < dataSet2.getSeriesCount(); i++, cIndex++) { renderer2.setSeriesStroke(i, wideLine); renderer2.setBaseShapesVisible(false); if (cIndex > 6) cIndex = 0; renderer2.setSeriesFillPaint(i, blueColors[cIndex]); renderer2.setSeriesPaint(i, blueColors[cIndex]); } plot.getRangeAxis(0).setLabelPaint(redColors[0]); plot.getRangeAxis(0).setTickLabelPaint(redColors[0]); plot.getRangeAxis(1).setLabelPaint(blueColors[0]); plot.getRangeAxis(1).setTickLabelPaint(blueColors[0]); } }
From source file:edu.ucla.stat.SOCR.chart.SuperPowerChart.java
protected void setTable(XYDataset ds) { convertor.Power2Table(ds);//from ww w. ja v a 2 s . c om //convertor.dataset2Table(dataset); JTable tempDataTable = convertor.getTable(); resetTableRows(tempDataTable.getRowCount() + 1); resetTableColumns(tempDataTable.getColumnCount()); for (int i = 0; i < tempDataTable.getColumnCount(); i++) { columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i)); // System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i)); } columnModel = dataTable.getColumnModel(); dataTable.setTableHeader(new EditableHeader(columnModel)); for (int i = 0; i < tempDataTable.getRowCount(); i++) for (int j = 0; j < tempDataTable.getColumnCount(); j++) { dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j); } dataPanel.removeAll(); dataPanel.add(new JScrollPane(dataTable)); dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); dataTable.doLayout(); // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003 try { dataTable.setDragEnabled(true); } catch (Exception e) { } dataPanel.validate(); // don't bring graph to the front if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) != ALL) { // tabbedPanelContainer.setSelectedIndex(tabbedPanelContainer.indexOfComponent(graphPanel)); } else { dataPanel2.removeAll(); dataPanel2.add(new JLabel(" ")); dataPanel2.add(new JLabel("Data")); JScrollPane dt = new JScrollPane(dataTable); dt.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y * 3 / 8)); dataPanel2.add(dt); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 6)); dataPanel2.add(st); st.validate(); dataPanel2.add(new JLabel(" ")); dataPanel2.add(new JLabel("Mapping")); mapPanel.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 2)); dataPanel2.add(mapPanel); dataPanel2.validate(); } }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java
@Test public void testConfigurationXMLWithColorArray() { ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); Color colorValue = config.colorArray[0]; assertEquals(Color.class, colorValue.getClass()); assertEquals(Color.gray, colorValue); assertEquals(3, config.colorArray.length); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationXMLWithColorList() { ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); Color colorValue = config.colorList.get(0); assertEquals(Color.class, colorValue.getClass()); assertEquals(Color.gray, colorValue); assertEquals(3, config.colorList.size()); }
From source file:GeMSE.GS.Analysis.Stats.OneSamplePCAPanel.java
private void Plot() { double[][] data = _principalComponents.getData(); if (data[0].length < 2) { JOptionPane.showMessageDialog(this, "An error occured when computing principal components. " + "\nRequire at least two principal components, but calculated " + String.valueOf(data[0].length) + "\n", "Not enough data", JOptionPane.ERROR_MESSAGE); return;/* w w w . j a v a 2 s .c o m*/ } float[] yAxisColor = new float[3]; Color.RGBtoHSB(255, 255, 255, yAxisColor); float[] hsbValues = new float[3]; Color.RGBtoHSB(16, 23, 67, hsbValues); float[] pcColor = new float[3]; Color.RGBtoHSB(255, 255, 0, pcColor); XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries("PC"); for (double[] d : data) series.add(d[0], d[1]); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot(null, "Principal component 1", "Principal component 2", (XYDataset) dataset); chart.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2])); chart.removeLegend(); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2])); Font axisLabelFont = new Font("Dialog", Font.PLAIN, 14); Font axisTickLabelFont = new Font("Dialog", Font.PLAIN, 12); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.white); plot.getDomainAxis().setLabelPaint(Color.white); plot.getDomainAxis().setLabelFont(axisLabelFont); plot.getDomainAxis().setTickLabelFont(axisTickLabelFont); plot.getRangeAxis().setTickLabelPaint(Color.getHSBColor(yAxisColor[0], yAxisColor[1], yAxisColor[2])); plot.getRangeAxis().setLabelPaint(Color.getHSBColor(yAxisColor[0], yAxisColor[1], yAxisColor[2])); plot.getRangeAxis().setLabelFont(axisLabelFont); plot.getRangeAxis().setTickLabelFont(axisTickLabelFont); Shape shape = ShapeUtilities.createDiagonalCross(4, 0.5f); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); renderer.setSeriesShape(0, shape); renderer.setSeriesPaint(0, Color.getHSBColor(pcColor[0], pcColor[1], pcColor[2])); ChartPanel panel = new ChartPanel(chart); Dimension plotDim = plotPanel.getSize(); plotDim.height -= (plotDim.height * 10) / 100; plotDim.width -= (plotDim.width * 10) / 100; panel.setPreferredSize(plotDim); plotPanel.setViewportView(panel); revalidate(); repaint(); }
From source file:br.gov.jfrj.itextpdf.Documento.java
public static byte[] stamp(byte[] abPdf, String sigla, boolean rascunho, boolean cancelado, boolean semEfeito, boolean internoProduzido, String qrCode, String mensagem, Integer paginaInicial, Integer paginaFinal, Integer cOmitirNumeracao, String instancia, String orgaoUsu) throws DocumentException, IOException { PdfReader pdfIn = new PdfReader(abPdf); Document doc = new Document(PageSize.A4, 0, 0, 0, 0); // final SimpleDateFormat sdf = new SimpleDateFormat( // "EEE MMM dd HH:mm:ss zzz yyyy"); // doc.add(new Meta("creationdate", sdf.format(new Date(0L)))); final ByteArrayOutputStream boA4 = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(doc, boA4); doc.open();/*from ww w . j a v a2 s.c om*/ PdfContentByte cb = writer.getDirectContent(); // Resize every page to A4 size // // double thetaRotation = 0.0; for (int i = 1; i <= pdfIn.getNumberOfPages(); i++) { int rot = pdfIn.getPageRotation(i); float left = pdfIn.getPageSize(i).getLeft(); float bottom = pdfIn.getPageSize(i).getBottom(); float top = pdfIn.getPageSize(i).getTop(); float right = pdfIn.getPageSize(i).getRight(); PdfImportedPage page = writer.getImportedPage(pdfIn, i); float w = page.getWidth(); float h = page.getHeight(); // Logger.getRootLogger().error("----- dimensoes: " + rot + ", " + w // + ", " + h); doc.setPageSize((rot != 0 && rot != 180) ^ (w > h) ? PageSize.A4.rotate() : PageSize.A4); doc.newPage(); cb.saveState(); if (rot != 0 && rot != 180) { float swap = w; w = h; h = swap; } float pw = doc.getPageSize().getWidth(); float ph = doc.getPageSize().getHeight(); double scale = Math.min(pw / w, ph / h); // do my transformations : cb.transform(AffineTransform.getScaleInstance(scale, scale)); if (!internoProduzido) { cb.transform(AffineTransform.getTranslateInstance(pw * SAFETY_MARGIN, ph * SAFETY_MARGIN)); cb.transform(AffineTransform.getScaleInstance(1.0f - 2 * SAFETY_MARGIN, 1.0f - 2 * SAFETY_MARGIN)); } if (rot != 0) { double theta = -rot * (Math.PI / 180); if (rot == 180) { cb.transform(AffineTransform.getRotateInstance(theta, w / 2, h / 2)); } else { cb.transform(AffineTransform.getRotateInstance(theta, h / 2, w / 2)); } if (rot == 90) { cb.transform(AffineTransform.getTranslateInstance((w - h) / 2, (w - h) / 2)); } else if (rot == 270) { cb.transform(AffineTransform.getTranslateInstance((h - w) / 2, (h - w) / 2)); } } // Logger.getRootLogger().error( // "----- dimensoes: " + rot + ", " + w + ", " + h); // Logger.getRootLogger().error("----- page: " + pw + ", " + ph); // cb.transform(AffineTransform.getTranslateInstance( // ((pw / scale) - w) / 2, ((ph / scale) - h) / 2)); // put the page cb.addTemplate(page, 0, 0); // draw a red rectangle at the page borders // // cb.saveState(); // cb.setColorStroke(Color.red); // cb.rectangle(pdfIn.getPageSize(i).getLeft(), pdfIn.getPageSize(i) // .getBottom(), pdfIn.getPageSize(i).getRight(), pdfIn // .getPageSize(i).getTop()); // cb.stroke(); // cb.restoreState(); cb.restoreState(); } doc.close(); abPdf = boA4.toByteArray(); final ByteArrayOutputStream bo2 = new ByteArrayOutputStream(); final PdfReader reader = new PdfReader(abPdf); final int n = reader.getNumberOfPages(); final PdfStamper stamp = new PdfStamper(reader, bo2); // adding content to each page int i = 0; PdfContentByte under; PdfContentByte over; final BaseFont helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false); // Image img = Image.getInstance("watermark.jpg"); final BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED); byte maskr[] = { (byte) 0xff }; Image mask = Image.getInstance(1, 1, 1, 1, maskr); mask.makeMask(); mask.setInverted(true); while (i < n) { i++; // watermark under the existing page under = stamp.getUnderContent(i); over = stamp.getOverContent(i); final Barcode39 code39 = new Barcode39(); // code39.setCode(doc.getCodigo()); code39.setCode(sigla.replace("-", "").replace("/", "").replace(".", "")); code39.setStartStopText(false); final Image image39 = code39.createImageWithBarcode(over, null, null); Rectangle r = stamp.getReader().getPageSizeWithRotation(i); image39.setInitialRotation((float) Math.PI / 2.0f); image39.setAbsolutePosition( r.getWidth() - image39.getHeight() + (STAMP_BORDER_IN_CM - PAGE_BORDER_IN_CM) * CM_UNIT, BARCODE_HEIGHT_IN_CM * CM_UNIT); image39.setBackgroundColor(Color.green); image39.setBorderColor(Color.RED); image39.setBorderWidth(0.5f * CM_UNIT); image39.setImageMask(mask); over.setRGBColorFill(255, 255, 255); mask.setAbsolutePosition(r.getWidth() - image39.getHeight() - (PAGE_BORDER_IN_CM) * CM_UNIT, (BARCODE_HEIGHT_IN_CM - STAMP_BORDER_IN_CM) * CM_UNIT); mask.scaleAbsolute(image39.getHeight() + 2 * STAMP_BORDER_IN_CM * CM_UNIT, image39.getWidth() + 2 * STAMP_BORDER_IN_CM * CM_UNIT); over.addImage(mask); over.setRGBColorFill(0, 0, 0); over.addImage(image39); // over.addImage(mask, mask.getScaledWidth() * 8, 0, 0, // mask.getScaledHeight() * 8, 100, 450); if (qrCode != null) { java.awt.Image imgQRCode = createQRCodeImage(qrCode); Image imageQRCode = Image.getInstance(imgQRCode, Color.BLACK, true); imageQRCode.scaleAbsolute(QRCODE_SIZE_IN_CM * CM_UNIT, QRCODE_SIZE_IN_CM * CM_UNIT); imageQRCode.setAbsolutePosition(QRCODE_LEFT_MARGIN_IN_CM * CM_UNIT, PAGE_BORDER_IN_CM * CM_UNIT); over.setRGBColorFill(255, 255, 255); mask.setAbsolutePosition((QRCODE_LEFT_MARGIN_IN_CM - STAMP_BORDER_IN_CM) * CM_UNIT, (PAGE_BORDER_IN_CM - STAMP_BORDER_IN_CM) * CM_UNIT); mask.scaleAbsolute((QRCODE_SIZE_IN_CM + 2 * STAMP_BORDER_IN_CM) * CM_UNIT, (QRCODE_SIZE_IN_CM + 2 * STAMP_BORDER_IN_CM) * CM_UNIT); over.addImage(mask); over.setRGBColorFill(0, 0, 0); over.addImage(imageQRCode); } if (mensagem != null) { PdfPTable table = new PdfPTable(1); table.setTotalWidth(r.getWidth() - image39.getHeight() - (QRCODE_LEFT_MARGIN_IN_CM + QRCODE_SIZE_IN_CM + 4 * STAMP_BORDER_IN_CM + PAGE_BORDER_IN_CM) * CM_UNIT); PdfPCell cell = new PdfPCell(new Paragraph(mensagem, FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, Color.BLACK))); cell.setBorderWidth(0); table.addCell(cell); over.setRGBColorFill(255, 255, 255); mask.setAbsolutePosition( (QRCODE_LEFT_MARGIN_IN_CM + QRCODE_SIZE_IN_CM + STAMP_BORDER_IN_CM) * CM_UNIT, (PAGE_BORDER_IN_CM - STAMP_BORDER_IN_CM) * CM_UNIT); mask.scaleAbsolute(2 * STAMP_BORDER_IN_CM * CM_UNIT + table.getTotalWidth(), 2 * STAMP_BORDER_IN_CM * CM_UNIT + table.getTotalHeight()); over.addImage(mask); over.setRGBColorFill(0, 0, 0); table.writeSelectedRows(0, -1, (QRCODE_LEFT_MARGIN_IN_CM + QRCODE_SIZE_IN_CM + 2 * STAMP_BORDER_IN_CM) * CM_UNIT, table.getTotalHeight() + PAGE_BORDER_IN_CM * CM_UNIT, over); } if (cancelado) { over.saveState(); final PdfGState gs = new PdfGState(); gs.setFillOpacity(0.5f); over.setGState(gs); over.setColorFill(Color.GRAY); over.beginText(); over.setFontAndSize(helv, 72); over.showTextAligned(Element.ALIGN_CENTER, "CANCELADO", r.getWidth() / 2, r.getHeight() / 2, 45); over.endText(); over.restoreState(); } else if (rascunho) { over.saveState(); final PdfGState gs = new PdfGState(); gs.setFillOpacity(0.5f); over.setGState(gs); over.setColorFill(Color.GRAY); over.beginText(); over.setFontAndSize(helv, 72); over.showTextAligned(Element.ALIGN_CENTER, "MINUTA", r.getWidth() / 2, r.getHeight() / 2, 45); over.endText(); over.restoreState(); } else if (semEfeito) { over.saveState(); final PdfGState gs = new PdfGState(); gs.setFillOpacity(0.5f); over.setGState(gs); over.setColorFill(Color.GRAY); over.beginText(); over.setFontAndSize(helv, 72); over.showTextAligned(Element.ALIGN_CENTER, "SEM EFEITO", r.getWidth() / 2, r.getHeight() / 2, 45); over.endText(); over.restoreState(); } // if (!rascunho // && request.getRequestURL().indexOf("http://laguna/") == -1) { if (!rascunho && !cancelado && !semEfeito && ((!Contexto.resource("isVersionTest").equals("false")) || (!Contexto.resource("isBaseTest").equals("false")))) { over.saveState(); final PdfGState gs = new PdfGState(); gs.setFillOpacity(0.5f); over.setGState(gs); over.setColorFill(Color.GRAY); over.beginText(); over.setFontAndSize(helv, 72); over.showTextAligned(Element.ALIGN_CENTER, "INVLIDO", r.getWidth() / 2, r.getHeight() / 2, 45); over.endText(); over.restoreState(); } // Imprime um circulo com o numero da pagina dentro. if (paginaInicial != null) { String sFl = String.valueOf(paginaInicial + i - 1); // Se for a ultima pagina e o numero nao casar, acrescenta "-" e // pagina final if (n == i) { if (paginaFinal != paginaInicial + n - 1) { sFl = sFl + "-" + String.valueOf(paginaFinal); } } if (i > cOmitirNumeracao) { // Raio do circulo interno final float radius = 18f; // Distancia entre o circulo interno e o externo final float circleInterspace = Math.max(helv.getAscentPoint(instancia, TEXT_HEIGHT), helv.getAscentPoint(orgaoUsu, TEXT_HEIGHT)) - Math.min(helv.getDescentPoint(instancia, TEXT_HEIGHT), helv.getDescentPoint(orgaoUsu, TEXT_HEIGHT)) + 2 * TEXT_TO_CIRCLE_INTERSPACE; // Centro do circulo float xCenter = r.getWidth() - 1.8f * (radius + circleInterspace); float yCenter = r.getHeight() - 1.8f * (radius + circleInterspace); over.saveState(); final PdfGState gs = new PdfGState(); gs.setFillOpacity(1f); over.setGState(gs); over.setColorFill(Color.BLACK); over.saveState(); over.setColorStroke(Color.black); over.setLineWidth(1f); over.setColorFill(Color.WHITE); // Circulo externo over.circle(xCenter, yCenter, radius + circleInterspace); over.fill(); over.circle(xCenter, yCenter, radius + circleInterspace); over.stroke(); // Circulo interno over.circle(xCenter, yCenter, radius); over.stroke(); over.restoreState(); { over.saveState(); over.beginText(); over.setFontAndSize(helv, TEXT_HEIGHT); // Escreve o texto superior do carimbo float fDescent = helv.getDescentPoint(instancia, TEXT_HEIGHT); showTextOnArc(over, instancia, helv, TEXT_HEIGHT, xCenter, yCenter, radius - fDescent + TEXT_TO_CIRCLE_INTERSPACE, true); // Escreve o texto inferior float fAscent = helv.getAscentPoint(orgaoUsu, TEXT_HEIGHT); showTextOnArc(over, orgaoUsu, helv, TEXT_HEIGHT, xCenter, yCenter, radius + fAscent + TEXT_TO_CIRCLE_INTERSPACE, false); over.endText(); over.restoreState(); } over.beginText(); int textHeight = 23; // Diminui o tamanho do font ate que o texto caiba dentro do // circulo interno while (helv.getWidthPoint(sFl, textHeight) > (2 * (radius - TEXT_TO_CIRCLE_INTERSPACE))) textHeight--; float fAscent = helv.getAscentPoint(sFl, textHeight) + helv.getDescentPoint(sFl, textHeight); over.setFontAndSize(helv, textHeight); over.showTextAligned(Element.ALIGN_CENTER, sFl, xCenter, yCenter - 0.5f * fAscent, 0); over.endText(); over.restoreState(); } } } stamp.close(); return bo2.toByteArray(); }
From source file:eu.planets_project.tb.impl.chart.ExperimentChartServlet.java
public JFreeChart createWallclockChart(String expId) { ExperimentPersistencyRemote edao = ExperimentPersistencyImpl.getInstance(); long eid = Long.parseLong(expId); log.info("Building experiment chart for eid = " + eid); Experiment exp = edao.findExperiment(eid); final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final String expName = exp.getExperimentSetup().getBasicProperties().getExperimentName(); boolean hasSuccesses = false; boolean hasFails = false; for (BatchExecutionRecordImpl batch : exp.getExperimentExecutable().getBatchExecutionRecords()) { int i = 1; List<ExecutionRecordImpl> runs = new ArrayList<ExecutionRecordImpl>(batch.getRuns()); Collections.sort(runs, new RunComparator()); for (ExecutionRecordImpl exr : runs) { //log.info("Found Record... "+exr+" stages: "+exr.getStages()); if (exr != null && exr.getStages() != null) { // Look up the object, so we can get the name. DigitalObjectRefBean dh = new DataHandlerImpl().get(exr.getDigitalObjectReferenceCopy()); String dobName = "Object " + i; if (dh != null) dobName = dh.getName(); ResultsForDigitalObjectBean res = new ResultsForDigitalObjectBean( exr.getDigitalObjectReferenceCopy()); Double time = null; boolean success = false; // First, attempt to pull from stage records: // FIXME: Note that this record is really at the wrong level. /*/*w w w.j a v a 2s . co m*/ if( exr.getStages().size() == 1 ) { for( ExecutionStageRecordImpl exsr : exr.getStages() ) { Double stageTime = exsr.getDoubleMeasurement( TecRegMockup.PROP_SERVICE_TIME ); if( stageTime != null ) { time = stageTime; success = exsr.isMarkedAsSuccessful(); } } } */ // Pick up from record duration: if (time == null && res.getExecutionDuration() != null) { //convert from milli seconds to seconds time = (double) res.getExecutionDuration() / 1000.0; success = res.getHasExecutionSucceededOK(); } log.info("Found DOB: {" + exr.getDigitalObjectReferenceCopy() + "} {" + dobName + "} w/ time " + time); if (res.getExecutionRecord() != null) log.info("Timing: " + res.getExecutionRecord().getStartDate() + " " + res.getExecutionRecord().getEndDate()); if (time != null) { if (success) { dataset.addValue(time, "Succeeded", dobName); hasSuccesses = true; } else { dataset.addValue(time, "Failed", dobName); hasFails = true; } } } // Increment, for the next run. i++; } } int si = dataset.getRowIndex("Succeeded"); int ri = dataset.getRowIndex("Failed"); // Create the chart. JFreeChart chart = ChartFactory.createStackedBarChart(null, "Digital Object", "Time [s]", dataset, PlotOrientation.VERTICAL, true, true, false); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); // set the range axis to display integers only... //final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); //rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0.0f, 0.9f, 0.0f)); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(0.9f, 0.0f, 0.0f)); if (hasSuccesses) renderer.setSeriesPaint(si, gp0); if (hasFails) renderer.setSeriesPaint(ri, gp1); // Set the tooltips... //renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator("xy_chart.jsp","series","section")); renderer.setBaseToolTipGenerator(new MeasurementToolTipGenerator()); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0)); // More settings chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Remove the border, as the SVG renderer has problems with the text overflowing. chart.getLegend().setBorder(0.0, 0.0, 0.0, 0.0); // Remove the padding between the axes and the plot: chart.getPlot().setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); // Set a gradient fill, fading towards the top: final GradientPaint gpb0 = new GradientPaint(0.0f, 0.0f, new Color(245, 245, 245), 0.0f, 0.0f, Color.white); chart.getPlot().setBackgroundPaint(gpb0); return chart; }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.reporting.AnnotationReportCanvas.java
private void xorRectangle(Point start_point, Point end_point) { Graphics g = getGraphics();// w w w . jav a 2s .c o m g.setXORMode(Color.white); g.setColor(Color.gray); Rectangle rect = makeRectangle(start_point, end_point); g.drawRect(rect.x, rect.y, rect.width, rect.height); }