Example usage for java.awt Font SANS_SERIF

List of usage examples for java.awt Font SANS_SERIF

Introduction

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

Prototype

String SANS_SERIF

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

Click Source Link

Document

A String constant for the canonical family name of the logical font "SansSerif".

Usage

From source file:com.willwinder.ugs.nbp.setupwizard.panels.WizardPanelStepCalibration.java

private void addHeaderRow(JPanel panel) {
    Font labelHeaderFont = new Font(Font.SANS_SERIF, Font.BOLD, 16);
    JLabel headerLabel = new JLabel(Localization.getString("platform.plugin.setupwizard.move"), JLabel.CENTER);
    headerLabel.setFont(labelHeaderFont);
    panel.add(headerLabel, "growx, spanx 3, gapbottom 5, gaptop 7");
    panel.add(new JSeparator(SwingConstants.VERTICAL), "spany 5, gapleft 5, gapright 5, wmin 10, grow");

    headerLabel = new JLabel(Localization.getString("platform.plugin.setupwizard.measure"), JLabel.CENTER);
    headerLabel.setFont(labelHeaderFont);
    panel.add(headerLabel, "growx, spanx 2, gapbottom 5, gaptop 7");
    panel.add(new JSeparator(SwingConstants.VERTICAL), "spany 5, gapleft 5, gapright 5, wmin 10, grow");

    headerLabel = new JLabel(Localization.getString("platform.plugin.setupwizard.calibrate"), JLabel.CENTER);
    headerLabel.setFont(labelHeaderFont);
    panel.add(headerLabel, "growx, spanx 3, wrap, gapbottom 5, gaptop 7");
}

From source file:com.willwinder.ugs.nbp.setupwizard.panels.WizardPanelStepCalibration.java

private void initComponents() {
    Font labelEstimatedFont = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
    navigationButtons = new NavigationButtons(getBackend(), 1.0,
            (int) getBackend().getSettings().getJogFeedRate());

    buttonUpdateSettingsX = new JButton(Localization.getString("platform.plugin.setupwizard.update"));
    buttonUpdateSettingsX.setEnabled(false);
    labelEstimatedStepsX = new JLabel("0 steps/mm");
    labelEstimatedStepsX.setFont(labelEstimatedFont);
    labelPositionX = new JLabel("  0.0 mm", JLabel.RIGHT);
    textFieldMeasuredX = new JTextField("0");
    textFieldMeasuredX.addKeyListener(createKeyListener(Axis.X, labelEstimatedStepsX));
    textFieldSettingStepsX = new JTextField("0");
    textFieldSettingStepsX.addKeyListener(createKeyListenerChangeSetting(Axis.X, buttonUpdateSettingsX));

    buttonUpdateSettingsY = new JButton(Localization.getString("platform.plugin.setupwizard.update"));
    buttonUpdateSettingsY.setEnabled(false);
    labelEstimatedStepsY = new JLabel(
            Localization.getString("platform.plugin.setupwizard.calibration.setting"));
    labelEstimatedStepsY.setFont(labelEstimatedFont);
    labelPositionY = new JLabel("  0.0 mm", JLabel.RIGHT);
    textFieldMeasuredY = new JTextField("0");
    textFieldMeasuredY.addKeyListener(createKeyListener(Axis.Y, labelEstimatedStepsY));
    textFieldSettingStepsY = new JTextField("0");
    textFieldSettingStepsY.addKeyListener(createKeyListenerChangeSetting(Axis.Y, buttonUpdateSettingsY));

    buttonUpdateSettingsZ = new JButton(Localization.getString("platform.plugin.setupwizard.update"));
    buttonUpdateSettingsZ.setEnabled(false);
    labelEstimatedStepsZ = new JLabel("0 steps/mm");
    labelEstimatedStepsZ.setFont(labelEstimatedFont);
    labelPositionZ = new JLabel("  0.0 mm", JLabel.RIGHT);
    textFieldMeasuredZ = new JTextField("0");
    textFieldMeasuredZ.addKeyListener(createKeyListener(Axis.Z, labelEstimatedStepsZ));
    textFieldSettingStepsZ = new JTextField("0");
    textFieldSettingStepsZ.addKeyListener(createKeyListenerChangeSetting(Axis.Z, buttonUpdateSettingsZ));
}

From source file:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java

public void interpolate(double[] results, String[] resultStrings) {
    hpAxis.setAutoRange(true);// ww  w . j  a  v a  2  s. c  o  m
    tqAxis.setAutoRange(true);
    double rangeMin = Math.min(tqAxis.getLowerBound(), hpAxis.getLowerBound());
    double yMin = Math.round(rangeMin);
    double ySpace = (hpAxis.getUpperBound() - hpAxis.getLowerBound()) / 25;
    double xMin = ((plot.getDomainAxis().getUpperBound() - plot.getDomainAxis().getLowerBound()) / 7)
            + plot.getDomainAxis().getLowerBound();
    hpAxis.setRange(Math.round(rangeMin), Math.round(hpAxis.getUpperBound() + ySpace));
    tqAxis.setRange(Math.round(rangeMin), Math.round(tqAxis.getUpperBound() + ySpace));
    bestHp = new XYDrawableAnnotation(results[1], results[0], 10, 10, cd);
    hpPointer.setX(results[1]);
    hpPointer.setY(results[0]);
    hpPointer.setArrowPaint(BLUE);
    hpPointer.setTipRadius(7.0);
    hpPointer.setBaseRadius(30.0);
    hpPointer.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    hpPointer.setPaint(BLUE);
    bestTq = new XYDrawableAnnotation(results[3], results[2], 10, 10, cd);
    tqPointer.setX(results[3]);
    tqPointer.setY(results[2]);
    tqPointer.setArrowPaint(YELLOW);
    tqPointer.setTipRadius(7.0);
    tqPointer.setBaseRadius(30.0);
    tqPointer.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10));
    tqPointer.setPaint(YELLOW);
    final XYTextAnnotation dynoResults = new XYTextAnnotation(resultStrings[1], xMin, yMin + (ySpace * 5));
    dynoResults.setPaint(RED);
    dynoResults.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    dynoResults.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14));
    final XYTextAnnotation carText = new XYTextAnnotation(resultStrings[0], xMin, yMin + (ySpace * 4));
    carText.setPaint(RED);
    carText.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    carText.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    final XYTextAnnotation stat1 = new XYTextAnnotation(resultStrings[2], xMin, yMin + (ySpace * 3));
    stat1.setPaint(RED);
    stat1.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat1.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    final XYTextAnnotation stat2 = new XYTextAnnotation(resultStrings[3], xMin, yMin + ySpace * 2);
    stat2.setPaint(RED);
    stat2.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat2.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    final XYTextAnnotation stat3 = new XYTextAnnotation(resultStrings[4], xMin, yMin + ySpace);
    stat3.setPaint(RED);
    stat3.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat3.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    final XYTextAnnotation stat4 = new XYTextAnnotation(resultStrings[5], xMin, yMin);
    stat4.setPaint(RED);
    stat4.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    stat4.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
    if (!refStat.equals(" ")) {
        refStat.setX(plot.getDomainAxis().getLowerBound() + 10);
        refStat.setY(hpAxis.getUpperBound());
        plot.addAnnotation(refStat);
    }
    rendererY1.addAnnotation(bestHp);
    rendererY2.addAnnotation(bestTq);
    rendererY1.addAnnotation(hpPointer);
    rendererY2.addAnnotation(tqPointer);
    plot.addAnnotation(dynoResults);
    plot.addAnnotation(carText);
    plot.addAnnotation(stat1);
    plot.addAnnotation(stat2);
    plot.addAnnotation(stat3);
    plot.addAnnotation(stat4);
}

From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java

private void setGeneralChart() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    int different = HandlerProxy.getRepositoryHandler().getDifferentSongsPlayed();
    int total = HandlerProxy.getRepositoryHandler().getSongs().size();
    dataset.setValue(LanguageTool.getString("SONGS_PLAYED"), different);
    dataset.setValue(LanguageTool.getString("SONGS_NEVER_PLAYED"), total - different);
    JFreeChart chart = ChartFactory.createPieChart3D(LanguageTool.getString("SONGS_PLAYED"), dataset, false,
            false, false);//w w w  . ja  v  a  2 s.  com
    chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0,
            200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR));
    chart.setPadding(new RectangleInsets(5, 0, 0, 0));
    chart.getPlot()
            .setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR,
                    0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR));
    DefaultDrawingSupplier drawingSupplier = new DefaultDrawingSupplier(
            new Paint[] { new Color(0, 1, 0, 0.6f), new Color(1, 0, 0, 0.6f) },
            new Paint[] { new Color(0, 1, 0, 0.4f), new Color(1, 0, 0, 0.4f) },
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
    chart.getPlot().setDrawingSupplier(drawingSupplier);
    ((StatsDialog) frameControlled).getGeneralChart()
            .setIcon(new ImageIcon(chart.createBufferedImage(710, 250)));
}

From source file:com.rapidminer.gui.viewer.metadata.model.AbstractAttributeStatisticsModel.java

/**
 * Changes the font of {@link JFreeChart}s to Sans Serif. This method uses a
 * {@link StandardChartTheme} to do so, so any changes to the look of the chart must be done
 * after calling this method.// www  .  j  a  v a 2s.co  m
 * 
 * @param chart
 *            the chart to change fonts for
 */
protected static void setDefaultChartFonts(JFreeChart chart) {
    final ChartTheme chartTheme = StandardChartTheme.createJFreeTheme();

    if (StandardChartTheme.class.isAssignableFrom(chartTheme.getClass())) {
        StandardChartTheme standardTheme = (StandardChartTheme) chartTheme;
        // The default font used by JFreeChart cannot render japanese etc symbols
        final Font oldExtraLargeFont = standardTheme.getExtraLargeFont();
        final Font oldLargeFont = standardTheme.getLargeFont();
        final Font oldRegularFont = standardTheme.getRegularFont();
        final Font oldSmallFont = standardTheme.getSmallFont();

        final Font extraLargeFont = new Font(Font.SANS_SERIF, oldExtraLargeFont.getStyle(),
                oldExtraLargeFont.getSize());
        final Font largeFont = new Font(Font.SANS_SERIF, oldLargeFont.getStyle(), oldLargeFont.getSize());
        final Font regularFont = new Font(Font.SANS_SERIF, oldRegularFont.getStyle(), oldRegularFont.getSize());
        final Font smallFont = new Font(Font.SANS_SERIF, oldSmallFont.getStyle(), oldSmallFont.getSize());

        standardTheme.setExtraLargeFont(extraLargeFont);
        standardTheme.setLargeFont(largeFont);
        standardTheme.setRegularFont(regularFont);
        standardTheme.setSmallFont(smallFont);

        standardTheme.apply(chart);
    }
}

From source file:gov.sandia.umf.platform.ui.jobs.RunPanel.java

public RunPanel() {
    root = new NodeBase();
    model = new DefaultTreeModel(root);
    tree = new JTree(model);
    tree.setRootVisible(false);/*from   w  ww  .  j  a v a  2s  .  c o m*/
    tree.setShowsRootHandles(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

    tree.setCellRenderer(new DefaultTreeCellRenderer() {
        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

            NodeBase node = (NodeBase) value;
            Icon icon = node.getIcon(expanded); // A node knows whether it should hold other nodes or not, so don't pass leaf to it.
            if (icon == null) {
                if (leaf)
                    icon = getDefaultLeafIcon();
                else if (expanded)
                    icon = getDefaultOpenIcon();
                else
                    icon = getDefaultClosedIcon();
            }
            setIcon(icon);

            return this;
        }
    });

    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            NodeBase newNode = (NodeBase) tree.getLastSelectedPathComponent();
            if (newNode == null)
                return;
            if (newNode == displayNode)
                return;

            if (displayThread != null)
                synchronized (displayText) {
                    displayThread.stop = true;
                }
            displayNode = newNode;
            if (displayNode instanceof NodeFile)
                viewFile();
            else if (displayNode instanceof NodeJob)
                viewJob();
        }
    });

    tree.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            int keycode = e.getKeyCode();
            if (keycode == KeyEvent.VK_DELETE || keycode == KeyEvent.VK_BACK_SPACE) {
                delete();
            }
        }
    });

    tree.addTreeWillExpandListener(new TreeWillExpandListener() {
        public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
            TreePath path = event.getPath(); // TODO: can this ever be null?
            Object o = path.getLastPathComponent();
            if (o instanceof NodeJob)
                ((NodeJob) o).build(tree);
        }

        public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
        }
    });

    tree.addTreeExpansionListener(new TreeExpansionListener() {
        public void treeExpanded(TreeExpansionEvent event) {
            Rectangle node = tree.getPathBounds(event.getPath());
            Rectangle visible = treePane.getViewport().getViewRect();
            visible.height -= node.y - visible.y;
            visible.y = node.y;
            tree.repaint(visible);
        }

        public void treeCollapsed(TreeExpansionEvent event) {
            Rectangle node = tree.getPathBounds(event.getPath());
            Rectangle visible = treePane.getViewport().getViewRect();
            visible.height -= node.y - visible.y;
            visible.y = node.y;
            tree.repaint(visible);
        }
    });

    Thread refreshThread = new Thread() {
        public void run() {
            try {
                // Initial load
                synchronized (running) {
                    for (MNode n : AppData.runs)
                        running.add(0, new NodeJob(n)); // This should be efficient on a doubly-linked list.
                    for (NodeJob job : running)
                        root.add(job);
                }
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        model.nodeStructureChanged(root);
                        if (model.getChildCount(root) > 0)
                            tree.setSelectionRow(0);
                    }
                });

                // Periodic refresh to show status of running jobs
                int shortCycles = 100; // Force full scan on first cycle.
                while (true) {
                    NodeBase d = displayNode; // Make local copy (atomic action) to prevent it changing from under us
                    if (d instanceof NodeJob)
                        ((NodeJob) d).monitorProgress(RunPanel.this);
                    if (shortCycles++ < 20) {
                        Thread.sleep(1000);
                        continue;
                    }
                    shortCycles = 0;

                    synchronized (running) {
                        Iterator<NodeJob> i = running.iterator();
                        while (i.hasNext()) {
                            NodeJob job = i.next();
                            if (job != d)
                                job.monitorProgress(RunPanel.this);
                            if (job.complete >= 1)
                                i.remove();
                        }
                    }
                }
            } catch (InterruptedException e) {
            }
        }
    };
    refreshThread.setDaemon(true);
    refreshThread.start();

    displayText = new JTextArea();
    displayText.setEditable(false);

    final JCheckBox chkFixedWidth = new JCheckBox("Fixed-Width Font");
    chkFixedWidth.setFocusable(false);
    chkFixedWidth.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int size = displayText.getFont().getSize();
            if (chkFixedWidth.isSelected()) {
                displayText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, size));
            } else {
                displayText.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, size));
            }
        }
    });

    displayPane.setViewportView(displayText);

    ActionListener graphListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (displayNode instanceof NodeFile) {
                NodeFile nf = (NodeFile) displayNode;
                if (nf.type == NodeFile.Type.Output || nf.type == NodeFile.Type.Result) {
                    String graphType = e.getActionCommand();
                    if (displayPane.getViewport().getView() instanceof ChartPanel
                            && displayGraph.equals(graphType)) {
                        viewFile();
                        displayGraph = "";
                    } else {
                        if (graphType.equals("Graph")) {
                            Plot plot = new Plot(nf.path.getAbsolutePath());
                            if (!plot.columns.isEmpty())
                                displayPane.setViewportView(plot.createGraphPanel());
                        } else // Raster
                        {
                            Raster raster = new Raster(nf.path.getAbsolutePath(), displayPane.getHeight());
                            displayPane.setViewportView(raster.createGraphPanel());
                        }
                        displayGraph = graphType;
                    }
                }
            }
        }
    };

    buttonGraph = new JButton("Graph", ImageUtil.getImage("analysis.gif"));
    buttonGraph.setFocusable(false);
    buttonGraph.addActionListener(graphListener);
    buttonGraph.setActionCommand("Graph");

    buttonRaster = new JButton("Raster", ImageUtil.getImage("prnplot.gif"));
    buttonRaster.setFocusable(false);
    buttonRaster.addActionListener(graphListener);
    buttonRaster.setActionCommand("Raster");

    Lay.BLtg(this, "C",
            Lay.SPL(Lay.BL("C", treePane = Lay.sp(tree)), Lay.BL("N",
                    Lay.FL(chkFixedWidth, Lay.FL(buttonGraph, buttonRaster), "hgap=50"), "C", displayPane),
                    "divpixel=250"));
    setFocusCycleRoot(true);
}

From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java

/**
 * Creates a chart displaying the radon concentration of a virtual campaign.
 * Uses red for normal rooms and blue for cellar rooms.
 * //from  w w  w.  j ava2s .  c  om
 * @param campaign
 *          The campaign object containing all rooms and radon data.
 * @param preview
 *          Will hide annotations, labels and headlines if true.
 * @return A chart displaying the radon concentration of a virtual campaign.
 */
public static JFreeChart createCampaignChart(OMCampaign campaign, boolean preview) {
    OMRoom[] rooms = new OMRoom[7];
    OMRoom[] tmpRooms = campaign.getRooms();
    OMRoom tmpCellar = campaign.getCellar();
    String variation = campaign.getVariation();
    char[] variationChar = variation.toCharArray();
    int cellarPosition = 0;
    for (int i = 0; i < variationChar.length; i++) {
        if (variationChar[i] == 'C' || variationChar[i] == 'c') {
            cellarPosition = i / 2;
        }
    }
    int c = 0;
    for (int i = 0; i < rooms.length; i++) {
        if (i == cellarPosition) {
            rooms[i] = tmpCellar;
            c++;
        } else {
            rooms[i] = tmpRooms[i - c];
        }
    }
    int start = campaign.getStart();
    final int finalStart = start;
    String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId() + rooms[3].getId()
            + rooms[4].getId() + rooms[5].getId() + rooms[6].getId() + ", Start: " + finalStart;
    int count = 168;
    double[] values = campaign.getValueChain();
    XYSeriesCollection dataSet = new XYSeriesCollection();
    XYSeries roomSeries1 = new XYSeries(" Radon Rooms");
    XYSeries cellarSeries = new XYSeries("Radon Cellar");
    XYSeries roomSeries2 = new XYSeries("Radon Rooms");
    int cellarSeriesStart = cellarPosition * 24;
    int cellarSeriesEnd = cellarSeriesStart + 24;
    double cellarMaximum = campaign.getCellarMaximum();
    double cellarMaximumKey = 0;
    double roomMaximum = campaign.getRoomMaximum();
    double roomMaximumKey = 0;
    if (cellarSeriesStart > 0) {
        for (int i = 0; i < cellarSeriesStart; i++) {
            roomSeries1.add(finalStart + i, values[i]);
            if (values[i] == roomMaximum) {
                roomMaximumKey = i;
            }
        }
    }
    for (int i = cellarSeriesStart - 1; i < cellarSeriesEnd; i++) {
        if (i >= 0) {
            cellarSeries.add(finalStart + i, values[i]);
            if (values[i] == cellarMaximum) {
                cellarMaximumKey = i;
            }
        }
    }
    if (cellarSeriesEnd < count) {
        for (int i = cellarSeriesEnd - 1; i < count; i++) {
            roomSeries2.add(finalStart + i, values[i]);
            if (values[i] == roomMaximum) {
                roomMaximumKey = i;
            }
        }
    }
    dataSet.addSeries(roomSeries1);
    dataSet.addSeries(cellarSeries);
    dataSet.addSeries(roomSeries2);
    JFreeChart chart = ChartFactory.createXYLineChart(title, "T [h]", "Rn [Bq/m\u00B3]", dataSet,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    ValueMarker sepMarker;
    Color sepColor = Color.BLACK;
    float[] sepDash = { 1, 2 };
    Stroke sepStroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, sepDash, 0);
    RectangleInsets sepLabelInsets = new RectangleInsets(20, -20, 0, 0);
    Font sepLabelFont = new Font(Font.SANS_SERIF, Font.BOLD, 16);
    sepMarker = new ValueMarker(finalStart + 0, sepColor, sepStroke);
    sepMarker.setLabel(rooms[0].getId());
    sepMarker.setLabelOffset(sepLabelInsets);
    sepMarker.setLabelFont(sepLabelFont);
    plot.addDomainMarker(sepMarker);
    if (rooms[0].getId() != rooms[1].getId()) {
        sepMarker = new ValueMarker(finalStart + 23, sepColor, sepStroke);
        sepMarker.setLabel(rooms[1].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    if (rooms[1].getId() != rooms[2].getId()) {
        sepMarker = new ValueMarker(finalStart + 47, sepColor, sepStroke);
        sepMarker.setLabel(rooms[2].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    if (rooms[2].getId() != rooms[3].getId()) {
        sepMarker = new ValueMarker(finalStart + 71, sepColor, sepStroke);
        sepMarker.setLabel(rooms[3].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    if (rooms[3].getId() != rooms[4].getId()) {
        sepMarker = new ValueMarker(finalStart + 95, sepColor, sepStroke);
        sepMarker.setLabel(rooms[4].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    if (rooms[4].getId() != rooms[5].getId()) {
        sepMarker = new ValueMarker(finalStart + 119, sepColor, sepStroke);
        sepMarker.setLabel(rooms[5].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    if (rooms[5].getId() != rooms[6].getId()) {
        sepMarker = new ValueMarker(finalStart + 143, sepColor, sepStroke);
        sepMarker.setLabel(rooms[6].getId());
        sepMarker.setLabelOffset(sepLabelInsets);
        sepMarker.setLabelFont(sepLabelFont);
        plot.addDomainMarker(sepMarker);
    }
    double positiveCellarDeviation = campaign.getCellarAverage() + campaign.getCellarDeviation();
    double negativeCellarDeviation = campaign.getCellarAverage() - campaign.getCellarDeviation();
    IntervalMarker cellarDeviation = new IntervalMarker(negativeCellarDeviation, positiveCellarDeviation);
    float[] dash = { 5, 3 };
    cellarDeviation.setPaint(new Color(222, 222, 255, 128));
    cellarDeviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(cellarDeviation, Layer.BACKGROUND);
    ValueMarker arithCellarMarker = new ValueMarker(campaign.getCellarAverage(), new Color(0, 0, 255, 128),
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(arithCellarMarker);
    XYTextAnnotation amCellarLabel = new XYTextAnnotation("C_AM=" + (int) campaign.getCellarAverage(),
            finalStart + count, campaign.getCellarAverage() * 1.01);
    plot.addAnnotation(amCellarLabel);
    XYTextAnnotation sdCellarLabel = new XYTextAnnotation("C_SD=" + (int) campaign.getCellarDeviation(),
            finalStart + count, (campaign.getCellarAverage() + campaign.getCellarDeviation()) * 1.01);
    plot.addAnnotation(sdCellarLabel);
    ValueMarker maxiCellarMarker = new ValueMarker(cellarMaximum, new Color(0, 0, 255, 128),
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(maxiCellarMarker);
    XYTextAnnotation maxCellarLabel = new XYTextAnnotation("C_MAX=" + (int) cellarMaximum, finalStart + count,
            cellarMaximum * 1.01);
    plot.addAnnotation(maxCellarLabel);
    XYPointerAnnotation maxCellarPointer = new XYPointerAnnotation("", finalStart + cellarMaximumKey,
            cellarMaximum, Math.PI * 1.1);
    plot.addAnnotation(maxCellarPointer);
    double positiveRoomDeviation = campaign.getRoomAverage() + campaign.getRoomDeviation();
    double negativeRoomDeviation = campaign.getRoomAverage() - campaign.getRoomDeviation();
    IntervalMarker roomDeviation = new IntervalMarker(negativeRoomDeviation, positiveRoomDeviation);
    roomDeviation.setPaint(new Color(255, 222, 222, 128));
    roomDeviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(roomDeviation, Layer.BACKGROUND);
    ValueMarker arithRoomMarker = new ValueMarker(campaign.getRoomAverage(), new Color(255, 0, 0, 128),
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(arithRoomMarker);
    XYTextAnnotation amRoomLabel = new XYTextAnnotation("R_AM=" + (int) campaign.getRoomAverage(),
            finalStart + count, campaign.getRoomAverage() * 1.01);
    plot.addAnnotation(amRoomLabel);
    XYTextAnnotation sdRoomLabel = new XYTextAnnotation("R_SD=" + (int) campaign.getRoomDeviation(),
            finalStart + count, (campaign.getRoomAverage() + campaign.getRoomDeviation()) * 1.01);
    plot.addAnnotation(sdRoomLabel);
    ValueMarker maxiRoomMarker = new ValueMarker(roomMaximum, new Color(255, 0, 0, 128),
            new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0));
    plot.addRangeMarker(maxiRoomMarker);
    XYTextAnnotation maxRoomLabel = new XYTextAnnotation("R_MAX=" + (int) roomMaximum, finalStart + count,
            roomMaximum * 1.01);
    plot.addAnnotation(maxRoomLabel);
    XYPointerAnnotation maxRoomPointer = new XYPointerAnnotation("", finalStart + roomMaximumKey, roomMaximum,
            Math.PI * 1.1);
    plot.addAnnotation(maxRoomPointer);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(255, 0, 0, 128));
    renderer.setSeriesPaint(1, new Color(0, 0, 255, 128));
    renderer.setSeriesPaint(2, new Color(255, 0, 0, 128));
    if (preview) {
        chart.setTitle("");
        plot.clearAnnotations();
    }
    return chart;
}

From source file:net.pms.util.GenericIcons.java

/**
 * Add the format(container) name of the media to the generic icon image.
 *
 * @param image BufferdImage to be the label added
 * @param label the media container name to be added as a label
 * @param renderer the renderer configuration
 *
 * @return the generic icon with the container label added and scaled in accordance with renderer setting
 *//* w  ww.  ja  v a2s.  c  o m*/
private DLNAThumbnail addFormatLabelToImage(String label, ImageFormat imageFormat, IconType iconType)
        throws IOException {

    BufferedImage image;
    switch (iconType) {
    case AUDIO:
        image = genericAudioIcon;
        break;
    case IMAGE:
        image = genericImageIcon;
        break;
    case VIDEO:
        image = genericVideoIcon;
        break;
    default:
        image = genericUnknownIcon;
    }

    if (image != null) {
        // Make a copy
        ColorModel colorModel = image.getColorModel();
        image = new BufferedImage(colorModel, image.copyData(null), colorModel.isAlphaPremultiplied(), null);
    }

    ByteArrayOutputStream out = null;

    if (label != null && image != null) {
        out = new ByteArrayOutputStream();
        Graphics2D g = image.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        try {
            int size = 40;
            Font font = new Font(Font.SANS_SERIF, Font.BOLD, size);
            FontMetrics metrics = g.getFontMetrics(font);
            while (size > 7 && metrics.stringWidth(label) > 135) {
                size--;
                font = new Font(Font.SANS_SERIF, Font.BOLD, size);
                metrics = g.getFontMetrics(font);
            }
            // Text center point 127x, 49y - calculate centering coordinates
            int x = 127 - metrics.stringWidth(label) / 2;
            int y = 46 + metrics.getAscent() / 2;
            g.drawImage(image, 0, 0, null);
            g.setColor(Color.WHITE);
            g.setFont(font);
            g.drawString(label, x, y);

            ImageIO.setUseCache(false);
            ImageIOTools.imageIOWrite(image, imageFormat.toString(), out);
        } finally {
            g.dispose();
        }
    }
    return out != null ? DLNAThumbnail.toThumbnail(out.toByteArray(), 0, 0, ScaleType.MAX, imageFormat, false)
            : null;
}

From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java

private void setArtistsChart() {
    DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedArtists(10));
    JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ARTIST_MOST_PLAYED"), null,
            null, dataset, PlotOrientation.HORIZONTAL, false, false, false);
    chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0,
            200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR));
    chart.setPadding(new RectangleInsets(5, 0, 0, 0));
    NumberAxis axis = new NumberAxis();
    axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));
    chart.getCategoryPlot().setRangeAxis(axis);
    chart.getCategoryPlot().setForegroundAlpha(0.6f);
    chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN);

    ((StatsDialog) frameControlled).getArtistsChart()
            .setIcon(new ImageIcon(chart.createBufferedImage(710, 250)));
}

From source file:de.fhbingen.wbs.wpOverview.tabs.AvailabilityGraph.java

/**
 * Creates a chart of the actual view with a title.
 * @param title//from w  w w  .  ja  v  a 2s .c  o m
 *            The title of the chart.
 */
protected final void makeChart(final String title) {
    DateTickUnit tick = null;
    switch (actualView) {
    case DAY:
        tick = new DateTickUnit(DateTickUnitType.HOUR, 1, new SimpleDateFormat("HH"));
        break;
    case WEEK:
        tick = new DateTickUnit(DateTickUnitType.DAY, 1, new SimpleDateFormat("E, dd.MM."));
        break;
    case MONTH:
        tick = new DateTickUnit(DateTickUnitType.DAY, 1, new SimpleDateFormat("d."));
        break;
    case YEAR:
        tick = new DateTickUnit(DateTickUnitType.MONTH, 1, new SimpleDateFormat("M"));
        break;
    default:
        break;
    }
    gui.pnlGraph.setChart(ChartFactory.createGanttChart(title, "", "", createDataset(), true, true, false));
    gui.pnlGraph.getChart().getTitle().setHorizontalAlignment(HorizontalAlignment.LEFT);
    gui.pnlGraph.getChart().getTitle().setMargin(5, 10, 5, 5);
    gui.pnlGraph.getChart().getCategoryPlot().getDomainAxis().setCategoryMargin(0.4);
    gui.pnlGraph.getChart().getCategoryPlot().getDomainAxis().setLowerMargin(0);
    gui.pnlGraph.getChart().getCategoryPlot().getDomainAxis().setUpperMargin(0);

    // chart.getCategoryPlot().getDomainAxis().getL

    gui.pnlGraph.getChart().getCategoryPlot().getDomainAxis()
            .setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));

    CategoryPlot plot = gui.pnlGraph.getChart().getCategoryPlot();
    DateAxis axis = (DateAxis) plot.getRangeAxis();
    axis.setMinimumDate(actualStart.getTime());
    axis.setMaximumDate(actualEnd.getTime());
    axis.setTickUnit(tick);

    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.green);
    renderer.setSeriesPaint(2, Color.red);
}