Example usage for java.awt Font BOLD

List of usage examples for java.awt Font BOLD

Introduction

In this page you can find the example usage for java.awt Font BOLD.

Prototype

int BOLD

To view the source code for java.awt Font BOLD.

Click Source Link

Document

The bold style constant.

Usage

From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java

private JPanel getJPanelForDocumentExportInfo() {
    if (jPanelForDocumentExportInfo == null) {
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints5.gridx = -1;//from   w w w. j av a2 s .c  om
        gridBagConstraints5.gridy = -1;
        gridBagConstraints5.gridwidth = 1;
        gridBagConstraints5.anchor = GridBagConstraints.CENTER;
        gridBagConstraints5.weightx = 1.0;
        gridBagConstraints5.weighty = 0.0;
        gridBagConstraints5.insets = new Insets(0, 0, 10, 5); //  margin // top, left, bottom, right
        jPanelForDocumentExportInfo = new JPanel();
        jPanelForDocumentExportInfo.setLayout(new GridBagLayout());
        jPanelForDocumentExportInfo.setBorder(BorderFactory.createTitledBorder(null, "Report Export Location",
                TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jPanelForDocumentExportInfo.add(getJPanelDocumentExportInfo(), gridBagConstraints5);
    }
    return jPanelForDocumentExportInfo;
}

From source file:FontPicker.java

protected void updatePreviewFont() {
    String name = StyleConstants.getFontFamily(attributes);
    boolean bold = StyleConstants.isBold(attributes);
    boolean ital = StyleConstants.isItalic(attributes);
    int size = StyleConstants.getFontSize(attributes);

    //Bold and italic don't work properly in beta 4.
    Font f = new Font(name, (bold ? Font.BOLD : 0) + (ital ? Font.ITALIC : 0), size);
    previewLabel.setFont(f);/*  w  w w  .ja  v  a2s .c  o  m*/
}

From source file:ColumnLayout.java

public ColumnLayoutPane() {
    // Specify a ColumnLayout LayoutManager, with right alignment
    this.setLayout(new ColumnLayout(5, 5, 10, ColumnLayout.RIGHT));

    // Create some buttons and set their sizes and positions explicitly
    for (int i = 0; i < 6; i++) {
        int pointsize = 8 + i * 2;
        JButton b = new JButton("Point size " + pointsize);
        b.setFont(new Font("helvetica", Font.BOLD, pointsize));
        this.add(b);
    }/*from w ww .  j av a2s .  com*/
}

From source file:org.jivesoftware.openfire.reporting.graph.GraphServlet.java

private void writePDFContent(HttpServletRequest request, HttpServletResponse response, JFreeChart charts[],
        Statistic[] stats, long starttime, long endtime, int width, int height) throws IOException {

    try {//from   w  w  w.  j a  va2  s.  co  m
        Document document = new Document(PageSize.A4, 50, 50, 50, 50);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        writer.setPageEvent(new PDFEventListener(request));
        document.open();

        int index = 0;
        int chapIndex = 0;
        for (Statistic stat : stats) {

            String serverName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
            String dateName = JiveGlobals.formatDate(new Date(starttime)) + " - "
                    + JiveGlobals.formatDate(new Date(endtime));
            Paragraph paragraph = new Paragraph(serverName,
                    FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD));
            document.add(paragraph);
            paragraph = new Paragraph(dateName, FontFactory.getFont(FontFactory.HELVETICA, 14, Font.PLAIN));
            document.add(paragraph);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);

            Paragraph chapterTitle = new Paragraph(++chapIndex + ". " + stat.getName(),
                    FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD));

            document.add(chapterTitle);
            // total hack: no idea what tags people are going to use in the description
            // possibly recommend that we only use a <p> tag?
            String[] paragraphs = stat.getDescription().split("<p>");
            for (String s : paragraphs) {
                Paragraph p = new Paragraph(s);
                document.add(p);
            }
            document.add(Chunk.NEWLINE);

            PdfContentByte contentByte = writer.getDirectContent();
            PdfTemplate template = contentByte.createTemplate(width, height);
            Graphics2D graphs2D = template.createGraphics(width, height, new DefaultFontMapper());
            Rectangle2D rectangle2D = new Rectangle2D.Double(0, 0, width, height);
            charts[index++].draw(graphs2D, rectangle2D);
            graphs2D.dispose();
            float x = (document.getPageSize().width() / 2) - (width / 2);
            contentByte.addTemplate(template, x, writer.getVerticalPosition(true) - height);
            document.newPage();
        }

        document.close();

        // setting some response headers
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        // setting the content type
        response.setContentType("application/pdf");
        // the contentlength is needed for MSIE!!!
        response.setContentLength(baos.size());
        // write ByteArrayOutputStream to the ServletOutputStream
        ServletOutputStream out = response.getOutputStream();
        baos.writeTo(out);
        out.flush();
    } catch (DocumentException e) {
        Log.error("error creating PDF document: " + e.getMessage());

    }
}

From source file:co.foldingmap.mapImportExport.SvgExporter.java

private void exportMapLabel(BufferedWriter outputStream, MapLabel label) {

    Color outlineColor, fillColor;
    float x, y;//from   w  ww.j a  v a 2 s .  co m
    Font labelFont;
    String style, fontStyle;

    try {
        labelFont = label.getFont();

        //construct style
        if (label.getFillColor() != null) {
            fillColor = label.getFillColor();
        } else {
            fillColor = Color.BLACK;
        }

        if (label.getOutlineColor() != null) {
            outlineColor = label.getOutlineColor();
        } else {
            outlineColor = Color.WHITE;
        }

        if (labelFont.getStyle() == Font.BOLD) {
            fontStyle = "font-weight=\"bold\"";
        } else if (labelFont.getStyle() == Font.PLAIN) {
            fontStyle = "font-style=\"normal\"";
        } else if (labelFont.getStyle() == Font.ITALIC) {
            fontStyle = "font-style=\"italic\"";
        } else {
            fontStyle = "";
        }

        style = "font-family=\"" + labelFont.getFamily() + "\" font-size=\"" + labelFont.getSize() + "\" "
                + fontStyle + " ";

        outputStream.write(getIndent());
        outputStream.write("<g " + style + ">\n");
        addIndent();

        style = "fill:#" + getHexColor(fillColor) + ";stroke:#" + getHexColor(outlineColor);

        if (label instanceof PointLabel) {
            PointLabel pointLabel = (PointLabel) label;

            x = pointLabel.getLine1StartPoint().x;
            y = pointLabel.getLine1StartPoint().y;

            outputStream.write(getIndent());
            outputStream.write("<text x=\"");
            outputStream.write(Float.toString(x));
            outputStream.write("\" y=\"");
            outputStream.write(Float.toString(y));
            outputStream.write("\" style=\"");
            outputStream.write(style);
            outputStream.write("\">\n");

            addIndent();
            outputStream.write(getIndent());
            outputStream.write("<tspan x=\"");
            outputStream.write(Float.toString(x));
            outputStream.write("\" y=\"");
            outputStream.write(Float.toString(y));
            outputStream.write("\">");
            outputStream.write(pointLabel.getLine1Text());
            outputStream.write("</tspan>\n");

            if (pointLabel.getLine2Text() != null && pointLabel.getLine2Text().length() > 0) {
                x = pointLabel.getLine2StartPoint().x;
                y = pointLabel.getLine2StartPoint().y;

                if (x != 0 && y != 0) {
                    outputStream.write(getIndent());
                    outputStream.write("<tspan x=\"");
                    outputStream.write(Float.toString(x));
                    outputStream.write("\" y=\"");
                    outputStream.write(Float.toString(y));
                    outputStream.write("\">");
                    outputStream.write(pointLabel.getLine2Text());
                    outputStream.write("</tspan>\n");
                }
            }

            removeIndent();
            outputStream.write(getIndent());
            outputStream.write("</text>\n");

            removeIndent();
            outputStream.write(getIndent());
            outputStream.write("</g>\n");
        } else if (label instanceof LineStringLabel) {
            LineStringLabel lineLabel = (LineStringLabel) label;

        } else if (label instanceof PolygonLabel) {
            PolygonLabel polyLabel = (PolygonLabel) label;

        }

    } catch (Exception e) {
        Logger.log(Logger.ERR, "Error in SvgExporter.exportMapLabel(BufferedWriter, MapLabel) - " + e);
    }
}

From source file:org.ietr.preesm.mapper.ui.MyGanttRenderer.java

/**
 * Draws the tasks/subtasks for one item.
 * // w ww  . j av  a 2s . com
 * @param g2
 *            the graphics device.
 * @param state
 *            the renderer state.
 * @param dataArea
 *            the data plot area.
 * @param plot
 *            the plot.
 * @param domainAxis
 *            the domain axis.
 * @param rangeAxis
 *            the range axis.
 * @param dataset
 *            the data.
 * @param row
 *            the row index (zero-based).
 * @param column
 *            the column index (zero-based).
 */
@Override
protected void drawTasks(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, GanttCategoryDataset dataset, int row,
        int column) {

    int count = dataset.getSubIntervalCount(row, column);
    if (count == 0) {
        drawTask(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column);
    }

    for (int subinterval = 0; subinterval < count; subinterval++) {

        RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge();

        // value 0
        Number value0 = dataset.getStartValue(row, column, subinterval);
        if (value0 == null) {
            return;
        }
        double translatedValue0 = rangeAxis.valueToJava2D(value0.doubleValue(), dataArea, rangeAxisLocation);

        // value 1
        Number value1 = dataset.getEndValue(row, column, subinterval);
        if (value1 == null) {
            return;
        }
        double translatedValue1 = rangeAxis.valueToJava2D(value1.doubleValue(), dataArea, rangeAxisLocation);

        if (translatedValue1 < translatedValue0) {
            double temp = translatedValue1;
            translatedValue1 = translatedValue0;
            translatedValue0 = temp;
        }

        double rectStart = calculateBarW0(plot, plot.getOrientation(), dataArea, domainAxis, state, row,
                column);
        double rectLength = Math.abs(translatedValue1 - translatedValue0);
        double rectBreadth = state.getBarWidth();

        // DRAW THE BARS...
        RoundRectangle2D bar = null;

        bar = new RoundRectangle2D.Double(translatedValue0, rectStart, rectLength, rectBreadth, 10.0, 10.0);

        /* Paint seriesPaint = */getItemPaint(row, column);

        if (((TaskSeriesCollection) dataset).getSeriesCount() > 0)
            if (((TaskSeriesCollection) dataset).getSeries(0).getItemCount() > column)
                if (((TaskSeriesCollection) dataset).getSeries(0).get(column).getSubtaskCount() > subinterval) {
                    g2.setPaint(getRandomBrightColor(((TaskSeriesCollection) dataset).getSeries(0).get(column)
                            .getSubtask(subinterval).getDescription()));

                }
        g2.fill(bar);

        if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
            g2.setStroke(getItemStroke(row, column));
            g2.setPaint(getItemOutlinePaint(row, column));
            g2.draw(bar);
        }

        // Displaying the tooltip inside the bar if enough space is
        // available
        if (getToolTipGenerator(row, column) != null) {
            // Getting the string to display
            String tip = getToolTipGenerator(row, column).generateToolTip(dataset, subinterval, column);

            // Truncting the string if it is too long
            String subtip = "";
            if (rectLength > 0) {
                double percent = (g2.getFontMetrics().getStringBounds(tip, g2).getWidth() + 10) / rectLength;

                if (percent > 1.0) {
                    subtip = tip.substring(0, (int) (tip.length() / percent));
                } else if (percent > 0) {
                    subtip = tip;
                }

                // Setting font and color
                Font font = new Font("Garamond", Font.BOLD, 12);
                g2.setFont(font);
                g2.setColor(Color.WHITE);

                // Testing width and displaying
                if (!subtip.isEmpty()) {
                    g2.drawString(subtip, (int) translatedValue0 + 5,
                            (int) rectStart + g2.getFontMetrics().getHeight());
                }
            }
        }

        // collect entity and tool tip information...
        if (state.getInfo() != null) {
            EntityCollection entities = state.getEntityCollection();
            if (entities != null) {
                String tip = null;
                if (getToolTipGenerator(row, column) != null) {
                    tip = getToolTipGenerator(row, column).generateToolTip(dataset, subinterval, column);
                }
                String url = null;
                if (getItemURLGenerator(row, column) != null) {
                    url = getItemURLGenerator(row, column).generateURL(dataset, row, column);
                }
                CategoryItemEntity entity = new CategoryItemEntity(bar, tip, url, dataset,
                        dataset.getRowKey(row), dataset.getColumnKey(column));
                entities.add(entity);
            }
        }
    }

}

From source file:com.mirth.connect.client.ui.NotificationDialog.java

private void initComponents() {
    setLayout(new MigLayout("insets 12", "[]", "[fill][]"));

    notificationPanel = new JPanel();
    notificationPanel.setLayout(new MigLayout("insets 0 0 0 0, fill", "[200!][]", "[25!]0[]"));
    notificationPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    archiveAll = new JLabel("Archive All");
    archiveAll.setForeground(java.awt.Color.blue);
    archiveAll.setText("<html><u>Archive All</u></html>");
    archiveAll.setToolTipText("Archive all notifications below.");
    archiveAll.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

    newNotificationsLabel = new JLabel();
    newNotificationsLabel.setFont(newNotificationsLabel.getFont().deriveFont(Font.BOLD));
    headerListPanel = new JPanel();
    headerListPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR);
    headerListPanel.setLayout(new MigLayout("insets 2, fill"));
    headerListPanel.setBorder(BorderFactory.createLineBorder(borderColor));

    list = new JList();
    list.setCellRenderer(new NotificationListCellRenderer());
    list.addListSelectionListener(new ListSelectionListener() {
        @Override//w  ww  .j  a  va2 s .  c o m
        public void valueChanged(ListSelectionEvent event) {
            if (!event.getValueIsAdjusting()) {
                currentNotification = (Notification) list.getSelectedValue();
                if (currentNotification != null) {
                    notificationNameTextField.setText(currentNotification.getName());
                    contentTextPane.setText(currentNotification.getContent());
                    archiveSelected();
                }
            }
        }
    });
    listScrollPane = new JScrollPane();
    listScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
    listScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor));
    listScrollPane.setViewportView(list);
    listScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    archiveLabel = new JLabel();
    archiveLabel.setForeground(java.awt.Color.blue);
    archiveLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

    notificationNameTextField = new JTextField();
    notificationNameTextField.setFont(notificationNameTextField.getFont().deriveFont(Font.BOLD));
    notificationNameTextField.setEditable(false);
    notificationNameTextField.setFocusable(false);
    notificationNameTextField.setBorder(BorderFactory.createEmptyBorder());
    notificationNameTextField.setBackground(UIConstants.HIGHLIGHTER_COLOR);
    DefaultCaret nameCaret = (DefaultCaret) notificationNameTextField.getCaret();
    nameCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    headerContentPanel = new JPanel();
    headerContentPanel.setLayout(new MigLayout("insets 2, fill"));
    headerContentPanel.setBorder(BorderFactory.createLineBorder(borderColor));
    headerContentPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR);

    contentTextPane = new JTextPane();
    contentTextPane.setContentType("text/html");
    contentTextPane.setEditable(false);
    contentTextPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            if (evt.getEventType() == EventType.ACTIVATED && Desktop.isDesktopSupported()) {
                try {
                    if (Desktop.isDesktopSupported()) {
                        Desktop.getDesktop().browse(evt.getURL().toURI());
                    } else {
                        BareBonesBrowserLaunch.openURL(evt.getURL().toString());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    });
    DefaultCaret contentCaret = (DefaultCaret) contentTextPane.getCaret();
    contentCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    contentScrollPane = new JScrollPane();
    contentScrollPane.setViewportView(contentTextPane);
    contentScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor));

    archiveLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            int index = list.getSelectedIndex();
            if (currentNotification.isArchived()) {
                notificationModel.setArchived(false, index);
                unarchivedCount++;
            } else {
                notificationModel.setArchived(true, index);
                unarchivedCount--;
            }
            archiveSelected();
            updateUnarchivedCountLabel();
        }
    });

    archiveAll.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            for (int i = 0; i < notificationModel.getSize(); i++) {
                notificationModel.setArchived(true, i);
            }
            unarchivedCount = 0;
            archiveSelected();
            updateUnarchivedCountLabel();
        }
    });

    notificationCheckBox = new JCheckBox("Show new notifications on login");
    notificationCheckBox.setBackground(UIConstants.BACKGROUND_COLOR);

    if (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications)) {
        checkForNotificationsSetting = true;
        if (showNotificationPopup == null || BooleanUtils.toBoolean(showNotificationPopup)) {
            notificationCheckBox.setSelected(true);
        } else {
            notificationCheckBox.setSelected(false);
        }
    } else {
        notificationCheckBox.setSelected(false);
    }

    notificationCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (notificationCheckBox.isSelected() && !checkForNotificationsSetting) {
                alertSettingsChange();
            }
        }
    });

    closeButton = new JButton("Close");
    closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doSave();
        }
    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            doSave();
        }
    });
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.MarkerTimeChartDecorator.java

/**
 * Creates a legend item block./*from   w w  w. j  a  va 2s.  com*/
 * 
 * @param item
 *            the legend item.
 * 
 * @return The block.
 */
protected Block createLegendItemBlock(LegendItem item, int i) {
    BlockContainer result = null;
    LegendGraphic lg = new LegendGraphic(item.getShape(), item.getFillPaint());
    lg.setFillPaintTransformer(item.getFillPaintTransformer());
    lg.setShapeFilled(true);
    lg.setLine(item.getLine());
    lg.setLineStroke(item.getLineStroke());
    lg.setLinePaint(item.getFillPaint());
    lg.setLineVisible(true);
    lg.setShapeVisible(true);
    lg.setShapeOutlineVisible(true);
    lg.setOutlinePaint(item.getFillPaint());
    lg.setOutlineStroke(item.getOutlineStroke());
    lg.setPadding(new RectangleInsets(2.0, 2.0, 2.0, 2.0));

    LegendItemBlockContainer legendItem = new LegendItemBlockContainer(new BorderArrangement(), 0, i);
    lg.setShapeAnchor(RectangleAnchor.CENTER);
    lg.setShapeLocation(RectangleAnchor.CENTER);
    legendItem.add(lg, RectangleEdge.LEFT);

    LabelBlock labelBlock = new LabelBlock(item.getLabel(), new Font("SansSerif", Font.BOLD, 10), Color.black);
    labelBlock.setPadding(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    legendItem.add(labelBlock);
    legendItem.setToolTipText(item.getToolTipText());
    legendItem.setURLText(item.getURLText());

    result = new BlockContainer(new CenterArrangement());
    result.add(legendItem);

    return result;
}

From source file:vteaexploration.plottools.panels.XYExplorationPanel.java

public void makeOverlayImage(ArrayList gates, int x, int y, int xAxis, int yAxis) {
    //convert gate to chart x,y path

    Gate gate;//from w  w  w  . j a va2s.c  o m
    ListIterator<Gate> gate_itr = gates.listIterator();

    //.get

    int total = 0;
    int gated = 0;
    int selected = 0;
    int gatedSelected = 0;

    int gatecount = gates.size();

    while (gate_itr.hasNext()) {
        gate = gate_itr.next();
        if (gate.getSelected()) {
            Path2D path = gate.createPath2DInChartSpace();

            ArrayList<MicroObject> result = new ArrayList<MicroObject>();

            ArrayList<MicroObject> volumes = (ArrayList) this.plotvalues.get(1);
            MicroObjectModel volume;

            double xValue = 0;
            double yValue = 0;

            ListIterator<MicroObject> it = volumes.listIterator();
            try {
                while (it.hasNext()) {
                    volume = it.next();
                    if (volume != null) {
                        xValue = ((Number) processPosition(xAxis, (MicroObject) volume)).doubleValue();
                        yValue = ((Number) processPosition(yAxis, (MicroObject) volume)).doubleValue();
                        if (path.contains(xValue, yValue)) {
                            result.add((MicroObject) volume);
                        }
                    }
                }
            } catch (NullPointerException e) {
            }
            ;

            Overlay overlay = new Overlay();

            int count = 0;
            BufferedImage placeholder = new BufferedImage(impoverlay.getWidth(), impoverlay.getHeight(),
                    BufferedImage.TYPE_INT_ARGB);

            ImageStack gateOverlay = new ImageStack(impoverlay.getWidth(), impoverlay.getHeight());

            selected = getSelectedObjects();

            total = volumes.size();

            gated = getGatedObjects(impoverlay);

            gatedSelected = getGatedSelected(impoverlay);

            for (int i = 0; i <= impoverlay.getNSlices(); i++) {
                BufferedImage selections = new BufferedImage(impoverlay.getWidth(), impoverlay.getHeight(),
                        BufferedImage.TYPE_INT_ARGB);

                Graphics2D g2 = selections.createGraphics();

                ImageRoi ir = new ImageRoi(0, 0, placeholder);
                ListIterator<MicroObject> vitr = result.listIterator();

                while (vitr.hasNext()) {
                    try {
                        MicroObject vol = (MicroObject) vitr.next();

                        int[] x_pixels = vol.getXPixelsInRegion(i);
                        int[] y_pixels = vol.getYPixelsInRegion(i);

                        for (int c = 0; c < x_pixels.length; c++) {

                            g2.setColor(gate.getColor());
                            g2.drawRect(x_pixels[c], y_pixels[c], 1, 1);
                        }
                        ir = new ImageRoi(0, 0, selections);
                        count++;

                    } catch (NullPointerException e) {
                    }
                }

                ir.setPosition(i);
                ir.setOpacity(0.4);
                overlay.add(ir);

                gateOverlay.addSlice(ir.getProcessor());

                java.awt.Font f = new Font("Arial", Font.BOLD, 12);
                BigDecimal percentage = new BigDecimal(selected);
                BigDecimal totalBD = new BigDecimal(total);
                percentage = percentage.divide(totalBD, 4, BigDecimal.ROUND_UP);

                BigDecimal percentageGated = new BigDecimal(gated);
                BigDecimal totalGatedBD = new BigDecimal(total);
                percentageGated = percentageGated.divide(totalGatedBD, 4, BigDecimal.ROUND_UP);

                BigDecimal percentageGatedSelected = new BigDecimal(gatedSelected);
                BigDecimal totalGatedSelectedBD = new BigDecimal(total);
                percentageGatedSelected = percentageGatedSelected.divide(totalGatedSelectedBD, 4,
                        BigDecimal.ROUND_UP);

                // System.out.println("PROFILING: gate fraction: " + percentage.toString());
                if (impoverlay.getWidth() > 256) {

                    TextRoi textTotal = new TextRoi(5, 10,
                            selected + "/" + total + " gated (" + 100 * percentage.doubleValue() + "%)");

                    if (gated > 0) {
                        textTotal = new TextRoi(5, 10, selected + "/" + total + " total ("
                                + 100 * percentage.doubleValue() + "%)" + "; " + gated + "/" + total + " roi ("
                                + 100 * percentageGated.doubleValue() + "%)" + "; " + gatedSelected + "/"
                                + total + " overlap (" + 100 * percentageGatedSelected.doubleValue() + "%)", f);
                    }
                    //TextRoi textImageGated = new TextRoi(5, 18, selected + "/" + total + " gated objects (" + 100 * percentage.doubleValue() + "%)", f);
                    textTotal.setPosition(i);
                    //textImageGated.setPosition(i);
                    overlay.add(textTotal);
                } else {
                    f = new Font("Arial", Font.PLAIN, 10);
                    TextRoi line1 = new TextRoi(5, 5,
                            selected + "/" + total + " gated" + "(" + 100 * percentage.doubleValue() + "%)", f);
                    overlay.add(line1);
                    if (gated > 0) {
                        f = new Font("Arial", Font.PLAIN, 10);
                        TextRoi line2 = new TextRoi(5, 18,
                                gated + "/" + total + " roi (" + 100 * percentageGated.doubleValue() + "%)", f);
                        overlay.add(line2);
                        TextRoi line3 = new TextRoi(5, 31, gatedSelected + "/" + total + " overlap ("
                                + 100 * percentageGatedSelected.doubleValue() + "%)", f);
                        overlay.add(line3);
                    }
                    line1.setPosition(i);

                }
            }
            impoverlay.setOverlay(overlay);

            //ImagePlus gateMaskImage = new ImagePlus("gates", gateOverlay);

            //gateMaskImage.show();

            gate.setGateOverlayStack(gateOverlay);

        }

        impoverlay.draw();
        impoverlay.setTitle(this.getTitle());

        if (impoverlay.getDisplayMode() != IJ.COMPOSITE) {
            impoverlay.setDisplayMode(IJ.COMPOSITE);
        }

        if (impoverlay.getSlice() == 1) {
            impoverlay.setZ(Math.round(impoverlay.getNSlices() / 2));
        } else {
            impoverlay.setSlice(impoverlay.getSlice());
        }
        impoverlay.show();
    }
}

From source file:edu.ku.brc.specify.utilapps.ERDTable.java

/**
 * @param font//from   w w w  . j  ava2 s .  co  m
 */
public void build(final Font font) {
    int numRows = 7;
    switch (displayType) {
    case All:
        numRows = 7;
        break;
    case MainFields:
        numRows = 7;
        break;
    case Title:
        numRows = 1;
        break;
    case TitleAndRel:
        numRows = 4;
        break;

    }
    Font bold = new Font(font.getFamily(), Font.BOLD, font.getSize());
    Font italic = new Font(font.getFamily(), Font.ITALIC, font.getSize());
    PanelBuilder pb = new PanelBuilder(
            new FormLayout("f:p:g", UIHelper.createDuplicateJGoodiesDef("p", "2px", numRows)));
    CellConstraints cc = new CellConstraints();

    String className = StringUtils.substringAfterLast(table.getClassName(), ".");
    DBTableInfo tblInfo = DBTableIdMgr.getInstance().getByShortClassName(className);
    if (tblInfo == null) {
        throw new RuntimeException("Couldn't find table for className[" + className + "]");
    }
    String tblName = tblInfo.getTitle();
    int y = 1;
    pb.add(ERDVisualizer.mkLabel(bold, tblName, SwingConstants.CENTER), cc.xy(1, y));
    y += 2;

    boolean doingAll = displayType == DisplayType.All;
    if (displayType == DisplayType.All || displayType == DisplayType.MainFields) {
        pb.addSeparator("", cc.xy(1, y));
        y += 2;

        pb.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_FIELDS"), SwingConstants.CENTER),
                cc.xy(1, y));
        y += 2;

        String colsDef = "p:g,4px,p:g,4px" + (doingAll ? ",p:g,4px,p:g,4px" : "") + ",f:p:g";
        PanelBuilder fieldsPB = new PanelBuilder(new FormLayout(colsDef,
                UIHelper.createDuplicateJGoodiesDef("p", "2px", table.getFields().size() + 2)));
        int yy = 1;

        fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_FIELD"), SwingConstants.LEFT),
                cc.xy(1, yy));
        fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TYPE"), SwingConstants.CENTER),
                cc.xy(3, yy));
        fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_LENGTH"), SwingConstants.CENTER),
                cc.xy(5, yy));
        if (doingAll) {
            fieldsPB.add(
                    ERDVisualizer.mkLabel(italic, getResourceString("ERD_REQUIRED"), SwingConstants.CENTER),
                    cc.xy(7, yy));
            fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_UNIQUE"), SwingConstants.CENTER),
                    cc.xy(9, yy));
        }
        yy += 2;

        if (StringUtils.isNotEmpty(table.getIdColumnName())) {
            build(fieldsPB, table, font, yy, doingAll); // does ID
            yy += 2;
        }

        for (DBFieldInfo f : table.getFields()) {
            build(fieldsPB, f, font, yy, doingAll);
            yy += 2;
        }
        pb.add(fieldsPB.getPanel(), cc.xy(1, y));
        y += 2;

    }

    if ((displayType == DisplayType.All || displayType == DisplayType.TitleAndRel)
            && table.getRelationships().size() > 0) {
        pb.addSeparator("", cc.xy(1, y));
        y += 2;

        pb.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_RELATIONSHIPS"), SwingConstants.CENTER),
                cc.xy(1, y));
        y += 2;

        String colsDef = "p:g,4px,p:g,4px" + (doingAll ? ",p:g,4px" : "") + ",f:p:g";
        PanelBuilder relsPB = new PanelBuilder(new FormLayout(colsDef,
                UIHelper.createDuplicateJGoodiesDef("p", "2px", table.getRelationships().size() + 1)));
        int yy = 1;

        relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TABLE"), SwingConstants.LEFT),
                cc.xy(1, yy));
        relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_NAME"), SwingConstants.CENTER),
                cc.xy(3, yy));
        relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TYPE"), SwingConstants.CENTER),
                cc.xy(5, yy));
        if (doingAll) {
            relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_REQUIRED"), SwingConstants.CENTER),
                    cc.xy(7, yy));
        }
        yy += 2;

        Vector<DBRelationshipInfo> orderedList = new Vector<DBRelationshipInfo>(table.getRelationships());
        Collections.sort(orderedList, new Comparator<DBRelationshipInfo>() {
            public int compare(DBRelationshipInfo o1, DBRelationshipInfo o2) {
                String name1 = ((DBRelationshipInfo) o1).getClassName();
                if (name1.startsWith("Sp")) {
                    name1 = name1.substring(2, name1.length());
                }
                String name2 = ((DBRelationshipInfo) o2).getClassName();
                if (name2.startsWith("Sp")) {
                    name2 = name2.substring(2, name2.length());
                }
                return name1.compareTo(name2);
            }
        });

        for (DBRelationshipInfo r : orderedList) {
            //System.out.println(r.getName()+" "+r.getType());
            if (!r.getName().toLowerCase().endsWith("iface")) {
                JComponent p = build(relsPB, r, font, yy, doingAll);
                relUIHash.put(r, p);
                yy += 2;
            }
        }
        pb.add(relsPB.getPanel(), cc.xy(1, y));
        y += 2;

        //fieldsPB.getPanel().setBackground(Color.GREEN);
        //relsPB.getPanel().setBackground(Color.BLUE);
    }

    inner = pb.getPanel();
    //inner.setBorder(BorderFactory.createEmptyBorder(BRD_GAP, BRD_GAP, BRD_GAP, BRD_GAP));

    inner.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK),
            BorderFactory.createEmptyBorder(BRD_GAP, BRD_GAP, BRD_GAP, BRD_GAP)));

    setBackground(Color.WHITE);
    add(inner, BorderLayout.CENTER);
}