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:net.sf.mzmine.modules.visualization.scatterplot.scatterplotchart.ScatterPlotRenderer.java

public ScatterPlotRenderer() {

    super(false, true);

    ScatterPlotToolTipGenerator toolTipGenerator = new ScatterPlotToolTipGenerator();
    setBaseToolTipGenerator(toolTipGenerator);

    XYItemLabelGenerator ItemlabelGenerator = new ScatterPlotItemLabelGenerator();
    setBaseItemLabelGenerator(ItemlabelGenerator);
    setBaseItemLabelFont(new Font("SansSerif", Font.BOLD, 11));
    setBaseItemLabelPaint(Color.black);
    setBaseItemLabelsVisible(false);/*from www.  j a v  a  2 s . c o  m*/

    setSeriesItemLabelsVisible(0, false);
    setSeriesPaint(0, pointColor);
    setSeriesShape(0, dataPointsShape);

    setSeriesItemLabelsVisible(1, false);
    setSeriesPaint(1, searchColor);
    setSeriesShape(1, dataPointsShape);

}

From source file:utils.ChartUtils.java

/**
 * Update IR bar chart//from   w  w w .  j av a2 s.  c o  m
 * 
 * @param labelsByFrequency Labels ordered by frequency
 * @param IR Imbalance Ratio values
 * @param cp CategoryPlot
 */
public static void updateIRBarChart(ImbalancedFeature[] labelsByFrequency, double[] IR, CategoryPlot cp) {
    DefaultCategoryDataset myData = new DefaultCategoryDataset();

    double prob = 0;

    labelsByFrequency = MetricUtils.sortByFrequency(labelsByFrequency);

    double sum = 0.0;
    for (int i = labelsByFrequency.length - 1; i >= 0; i--) {
        prob = IR[i];
        sum += prob;
        myData.setValue(prob, labelsByFrequency[i].getName(), " ");
    }

    cp.setDataset(myData);

    // add mean mark
    sum = sum / labelsByFrequency.length;
    Marker meanMark = new ValueMarker(sum);
    meanMark.setPaint(Color.red);
    meanMark.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
    meanMark.setLabel("                        Mean: " + MetricUtils.truncateValue(sum, 3));
    cp.addRangeMarker(meanMark);

    //Add Imbalance limit mark
    Marker limitMark = new ValueMarker(1.5);
    limitMark.setPaint(Color.black);
    limitMark.setLabelFont(new Font("SansSerif", Font.BOLD, 12));

    if ((sum < 1.3) || (sum > 1.7)) {
        limitMark.setLabel("                                                Imbalance limit (IR=1.5)");
    }
    cp.addRangeMarker(limitMark);
}

From source file:com.us.servlet.AuthCode.java

protected void service(HttpServletRequest request, HttpServletResponse response) {
    final CodeAuth bean = AppHelper.CODE_AUTH;
    int width = NumberUtils.toInt(request.getParameter("width"), bean.getWidth());
    int height = NumberUtils.toInt(request.getParameter("height"), bean.getHeight());
    int x = width / (bean.getLength() + 1);
    int codeY = height - 4;
    int fontHeight = height - 2;
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
    Graphics2D graphics = image.createGraphics();
    graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    if (StringUtil.hasText(request.getParameter("bgcolor"))) {
        graphics.setBackground(ColorHelper.hex2RGB(request.getParameter("bgcolor")));
    }// www  .j  ava2s .  c  o m
    graphics.fillRect(0, 0, width, height);
    graphics.setFont(new Font(bean.getFont(), Font.BOLD, fontHeight));
    graphics.drawRect(0, 0, width - 1, height - 1);
    // 
    if (bean.isBreakLine()) {
        for (int i = 0; i < 15; i++) {
            int x1 = RandomUtils.nextInt(width);
            int y1 = RandomUtils.nextInt(height);
            int x2 = RandomUtils.nextInt(12);
            int y2 = RandomUtils.nextInt(12);
            graphics.drawLine(x1, y1, x + x2, y1 + y2);
        }
    }
    char[] CHARSET_AREA = null;
    if (bean.getType().charAt(0) == '1') {
        CHARSET_AREA = ArrayUtils.addAll(CHARSET_AREA, BIG_LETTERS);
    }
    if (bean.getType().charAt(1) == '1') {
        CHARSET_AREA = ArrayUtils.addAll(CHARSET_AREA, SMALL_LETTER);
    }
    if (bean.getType().charAt(2) == '1') {
        CHARSET_AREA = ArrayUtils.addAll(CHARSET_AREA, NUMBERS);
    }
    StringBuilder randomCode = new StringBuilder();
    for (int i = 0; i < bean.getLength(); i++) {
        String rand = String.valueOf(CHARSET_AREA[RandomUtils.nextInt(CHARSET_AREA.length)]);
        graphics.setColor(ColorHelper.color(RandomUtils.nextInt(255), RandomUtils.nextInt(255),
                RandomUtils.nextInt(255)));
        graphics.drawString(rand, (i + 1) * x, codeY);
        randomCode.append(rand);
    }
    HttpSession session = request.getSession();
    session.setAttribute(bean.getSessionKey(), randomCode.toString());
    // ?
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
    response.setContentType("image/png");
    try {
        // Servlet?
        ServletOutputStream sos = response.getOutputStream();
        ImageIO.write(image, "png", sos);
        sos.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.haskins.cloudtrailviewer.utils.ChartFactory.java

private static ChartPanel createPieChart(String type, List<Entry<String, Integer>> events, int width,
        int height) {

    DefaultPieDataset dataset = new DefaultPieDataset();

    for (Map.Entry<String, Integer> event : events) {
        dataset.setValue(event.getKey(), event.getValue());
    }/*from   ww w  .  ja  v  a  2  s.  c  om*/

    JFreeChart jFChart;
    if (type.contains("3d")) {
        jFChart = org.jfree.chart.ChartFactory.createPieChart3D("", dataset, false, true, false);
    } else {
        jFChart = org.jfree.chart.ChartFactory.createPieChart("", dataset, false, true, false);
    }

    PiePlot plot = (PiePlot) jFChart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.01);
    plot.setOutlineVisible(false);
    plot.setLabelGenerator(null);

    // use gradients and white borders for the section colours
    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    TextTitle t = jFChart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setFont(new Font("Arial", Font.BOLD, 16));

    final ChartPanel jChartPanel = new ChartPanel(jFChart, width, height, width, height, width, height, false,
            false, true, true, false, true);
    jChartPanel.setMinimumDrawWidth(0);
    jChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    jChartPanel.setMinimumDrawHeight(0);
    jChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);

    return jChartPanel;
}

From source file:FileViewer.java

/**
 * The real constructor. Create a FileViewer object to display the specified
 * file from the specified directory/*from  ww w .  j  a v a 2  s  .com*/
 */
public FileViewer(String directory, String filename) {
    super(); // Create the frame

    // Destroy the window when the user requests it
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            dispose();
        }
    });

    // Create a TextArea to display the contents of the file in
    textarea = new TextArea("", 24, 80);
    textarea.setFont(new Font("MonoSpaced", Font.PLAIN, 12));
    textarea.setEditable(false);
    this.add("Center", textarea);

    // Create a bottom panel to hold a couple of buttons in
    Panel p = new Panel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5));
    this.add(p, "South");

    // Create the buttons and arrange to handle button clicks
    Font font = new Font("SansSerif", Font.BOLD, 14);
    Button openfile = new Button("Open File");
    Button close = new Button("Close");
    openfile.addActionListener(this);
    openfile.setActionCommand("open");
    openfile.setFont(font);
    close.addActionListener(this);
    close.setActionCommand("close");
    close.setFont(font);
    p.add(openfile);
    p.add(close);

    this.pack();

    // Figure out the directory, from filename or current dir, if necessary
    if (directory == null) {
        File f;
        if ((filename != null) && (f = new File(filename)).isAbsolute()) {
            directory = f.getParent();
            filename = f.getName();
        } else
            directory = System.getProperty("user.dir");
    }

    this.directory = directory; // Remember the directory, for FileDialog
    setFile(directory, filename); // Now load and display the file
}

From source file:com.lixiaocong.service.ImageCodeService.java

public BufferedImage getImage(HttpSession session) {
    //background//www .  j ava  2 s  .c  om
    BufferedImage bi = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
    Graphics graphics = bi.getGraphics();
    graphics.setColor(randomColor());
    graphics.fillRect(0, 0, WIDTH, HEIGHT);

    //content
    StringBuilder sb = new StringBuilder();
    int len = ch.length;
    Random random = new Random();
    for (int i = 0; i < 4; i++) {
        int index = random.nextInt(len);
        graphics.setColor(randomColor());
        graphics.setFont(new Font(null, Font.BOLD + Font.ITALIC, 30));
        graphics.drawString(ch[index] + "", i * 15 + 5, 25);
        sb.append(ch[index]);
    }
    session.setAttribute("imagecode", sb.toString());

    //lines
    for (int i = 0; i < 4; i++) {
        graphics.setColor(randomColor());
        graphics.drawLine(random.nextInt(WIDTH), random.nextInt(HEIGHT), random.nextInt(WIDTH),
                random.nextInt(HEIGHT));
    }

    return bi;
}

From source file:SwingTypeTester8.java

private void initComponents() {
    handler = new CharacterEventHandler();
    producer = new RandomCharacterGenerator();
    producer.setDone(true);// w w w .j a  v  a  2s . c o  m
    producer.start();
    displayCanvas = new AnimatedCharacterDisplayCanvas(producer);
    feedbackCanvas = new CharacterDisplayCanvas(this);
    quitButton = new JButton();
    startButton = new JButton();
    stopButton = new JButton();
    score = new ScoreLabel(producer, this);

    Container pane = getContentPane();
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.PAGE_AXIS));
    p1.add(displayCanvas);
    p1.add(feedbackCanvas);

    JPanel p2 = new JPanel();
    score.setText("      ");
    score.setFont(new Font("MONOSPACED", Font.BOLD, 30));
    p2.add(score);
    startButton.setText("Start");
    p2.add(startButton);
    stopButton.setText("Stop");
    stopButton.setEnabled(false);
    p2.add(stopButton);
    quitButton.setText("Quit");
    p2.add(quitButton);
    p1.add(p2);
    pane.add(p1, BorderLayout.NORTH);
    pack();

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            quit();
        }
    });
    feedbackCanvas.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent ke) {
            char c = ke.getKeyChar();
            if (c != KeyEvent.CHAR_UNDEFINED)
                newCharacter((int) c);
        }
    });
    startButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            displayCanvas.setDone(false);
            producer.setDone(false);
            score.resetScore();
            startButton.setEnabled(false);
            stopButton.setEnabled(true);
            feedbackCanvas.setEnabled(true);
            feedbackCanvas.requestFocus();
        }
    });
    stopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            startButton.setEnabled(true);
            stopButton.setEnabled(false);
            producer.setDone(true);
            displayCanvas.setDone(true);
            feedbackCanvas.setEnabled(false);
        }
    });
    quitButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            quit();
        }
    });
}

From source file:net.shopxx.CaptchaEngine.java

public void afterPropertiesSet() throws Exception {
    Assert.state(imageWidth > 0);//from  www  .  j  av  a  2s  . c om
    Assert.state(imageHeight > 0);
    Assert.state(minFontSize > 0);
    Assert.state(maxFontSize > 0);
    Assert.state(minWordLength > 0);
    Assert.state(maxWordLength > 0);
    Assert.hasText(charString);

    Font[] fonts = new Font[] { new Font("Arial", Font.BOLD, maxFontSize),
            new Font("Bell", Font.BOLD, maxFontSize), new Font("Credit", Font.BOLD, maxFontSize),
            new Font("Impact", Font.BOLD, maxFontSize) };
    FontGenerator fontGenerator = new RandomFontGenerator(minFontSize, maxFontSize, fonts);
    BackgroundGenerator backgroundGenerator = StringUtils.isNotEmpty(backgroundImagePath)
            ? new FileReaderRandomBackgroundGenerator(imageWidth, imageHeight,
                    servletContext.getRealPath(backgroundImagePath))
            : new FunkyBackgroundGenerator(imageWidth, imageHeight);
    TextPaster textPaster = new RandomTextPaster(minWordLength, maxWordLength, Color.WHITE);
    CaptchaFactory[] captchaFactories = new CaptchaFactory[] {
            new GimpyFactory(new RandomWordGenerator(charString),
                    new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster)) };
    super.setFactories(captchaFactories);
}

From source file:TrackerPanel.java

public TrackerPanel() {
    setBackground(Color.GRAY);//from w ww .  j  ava2  s . c o m

    df = new DecimalFormat("0.#"); // 1 dp
    msgFont = new Font("SansSerif", Font.BOLD, 13);

    configOpenNI();

    histogram = new float[MAX_DEPTH_SIZE];

    imWidth = depthMD.getFullXRes();
    imHeight = depthMD.getFullYRes();
    setSize(imWidth * 2, imHeight);
    System.out.println("Image dimensions (" + imWidth + ", " + imHeight + ")");
    // create empty image bytes array of correct size and type
    imgbytes = new byte[imWidth * imHeight * 3];
    hideBGPixel = new Color(0, 0, 255, 0).getRGB();

    // create d.s for holding camera pixels and image
    cameraPixels = new int[imWidth * imHeight];
    cameraImage = new BufferedImage(imWidth, imHeight, BufferedImage.TYPE_INT_ARGB);
    // the image must have an alpha channel for the transparent blue pixels

    new Thread(this).start(); // start updating the panel
}

From source file:de.fub.maps.project.detector.model.inference.ui.charts.AttributeSelectionBarChart.java

/**
 * Creates new form AttributeSelectionBarChart
 *//*from w  ww .  ja  va2  s.c o  m*/
public AttributeSelectionBarChart() {
    initComponents();
    barChart = ChartFactory.createBarChart(
            NbBundle.getMessage(AttributeSelectionBarChart.class, "AttributeSelectionBarChart.CLT_Chart_Title"),
            NbBundle.getMessage(AttributeSelectionBarChart.class,
                    "AttributeSelectionBarChart.CLT_Domain_Axis_Name"),
            NbBundle.getMessage(AttributeSelectionBarChart.class,
                    "AttributeSelectionBarChart.CLT_Value_Axis_Name"),
            dataset, PlotOrientation.VERTICAL, true, true, true);
    plot = barChart.getCategoryPlot();
    Font font = new JLabel().getFont().deriveFont(Font.BOLD, 14);

    barChart.getTitle().setFont(font);
    barChart.getTitle().setPaint(new Color(153, 153, 153));

    plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT);

    plot.setBackgroundPaint(Color.white);
    plot.getRangeAxis().setAutoRange(true);
    plot.getRangeAxis().setUpperMargin(.1);

    BarRenderer barRenderer = new BarRenderer();
    barRenderer.setBarPainter(new StandardBarPainter());
    barRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    barRenderer.setBaseFillPaint(Color.BLUE);
    barRenderer.setBasePaint(Color.BLUE);
    barRenderer.setAutoPopulateSeriesFillPaint(false);
    barRenderer.setAutoPopulateSeriesPaint(false);
    barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat()));
    barRenderer.setBaseItemLabelsVisible(true);

    plot.setRenderer(barRenderer);
    chartPanel = new ChartPanel(barChart, false);
    chartPanel.setVerticalAxisTrace(false);
    add(chartPanel, BorderLayout.CENTER);
}