List of usage examples for java.awt Font Font
private Font(String name, int style, float sizePts)
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.PieChart3DRenderer.java
public void createChart() { PieDataset dataset = (PieDataset) this.datasetStrategy.getDataset(); report = ChartFactory.createPieChart3D(this.datasetStrategy.getTitle(), dataset, false, true, true); PiePlot3D plot3D = (PiePlot3D) report.getPlot(); plot3D.setDirection(Rotation.ANTICLOCKWISE); plot3D.setStartAngle(PieChart3DRenderer.START_ANGLE); plot3D.setForegroundAlpha(PieChart3DRenderer.FOREGROUND_ALPHA); plot3D.setLabelFont(new Font("Lucida", 0, PieChart3DRenderer.FONT_SIZE)); }
From source file:ShowString.java
ShowString(String target, String title) { setTitle(title);//from w ww . j a v a 2 s .co m outString = target; Font font = new Font("Monospaced", Font.PLAIN, 36); fontM = getFontMetrics(font); setFont(font); int size = 0; for (int i = 0; i < outString.length(); i++) { size += fontM.charWidth(outString.charAt(i)); } size += 24; setSize(size, fontM.getHeight() + 60); setLocation(getSize().width / 2, getSize().height / 2); setVisible(true); }
From source file:cn.edu.thss.iise.bpmdemo.charts.SWTPieChartDemo1.java
/** * Creates a chart.//from ww w . j ava 2 s . c o m * * @param dataset * the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", // chart // title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
From source file:FileViewer.java
/** * The real constructor. Create a FileViewer object to display the specified * file from the specified directory//from w ww.ja v a 2s . c o m */ 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:client.ui.UploadFileWindow.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./*from www .j a va 2s . co m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { filePathLabel = new JLabel(); pathField = new JTextField(); pathButton = new JButton(); filenameLabel = new JLabel(); filenameField = new JTextField(); confirmButton = new JButton(); filenameTip = new JLabel(); FormListener formListener = new FormListener(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(""); setResizable(false); filePathLabel.setFont(new Font("", 0, 12)); // NOI18N filePathLabel.setText(""); pathField.setFont(new Font("", 0, 12)); // NOI18N pathButton.setFont(new Font("", 0, 12)); // NOI18N pathButton.setText("?"); pathButton.addActionListener(formListener); filenameLabel.setFont(new Font("", 0, 12)); // NOI18N filenameLabel.setText("??"); filenameField.setFont(new Font("", 0, 12)); // NOI18N confirmButton.setFont(new Font("", 0, 12)); // NOI18N confirmButton.setText(""); confirmButton.addActionListener(formListener); filenameTip.setFont(new Font("", 0, 12)); // NOI18N filenameTip.setForeground(new Color(153, 153, 153)); filenameTip.setText("???"); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createSequentialGroup().addGap(19, 19, 19) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(filePathLabel).addComponent(filenameLabel)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(filenameTip) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(pathField, GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE) .addComponent(filenameField)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(pathButton)))) .addGroup(layout.createSequentialGroup().addGap(167, 167, 167).addComponent(confirmButton))) .addContainerGap(33, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(filePathLabel) .addComponent(pathField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(pathButton)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(filenameLabel) .addComponent(filenameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(filenameTip) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE) .addComponent(confirmButton).addContainerGap())); pack(); }
From source file:net.sf.profiler4j.console.MemoryPlotPanel.java
public MemoryPlotPanel(int maxAge, String title) { super(new BorderLayout()); totalSeries = new TimeSeries("Committed Memory", Millisecond.class); totalSeries.setMaximumItemAge(maxAge); usedSeries = new TimeSeries("Used Memory", Millisecond.class); usedSeries.setMaximumItemAge(maxAge); TimeSeriesCollection seriesCollection = new TimeSeriesCollection(); seriesCollection.addSeries(totalSeries); seriesCollection.addSeries(usedSeries); NumberAxis numberAxis = new NumberAxis("Memory (KB)"); numberAxis.setLabelFont(new Font("SansSerif", 0, 14)); numberAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); DateAxis dateAxis = new DateAxis("Time"); dateAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); dateAxis.setLabelFont(new Font("SansSerif", 0, 14)); dateAxis.setAutoRange(true);//from ww w . j a v a 2 s. c o m dateAxis.setLowerMargin(0); dateAxis.setUpperMargin(0); dateAxis.setTickLabelsVisible(true); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); lineRenderer.setSeriesPaint(0, Color.RED); lineRenderer.setSeriesPaint(1, Color.GREEN.darker()); lineRenderer.setStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart chart = new JFreeChart(title, new Font("SansSerif", Font.PLAIN, 14), xyplot, true); chart.setBackgroundPaint(Color.white); ChartPanel panel = new ChartPanel(chart); panel.setBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createLineBorder(Color.LIGHT_GRAY))); add(panel); setBorder(createEmptyBorder(8, 8, 8, 8)); }
From source file:costumetrade.common.verify.ImageVerification.java
public Pair<String, BufferedImage> create() { int x = 0, fontHeight = 0, codeY = 0; int red = 0, green = 0, blue = 0; x = width / (codeCount + 2);//? fontHeight = height - 2;// codeY = height - 4;//from w w w .j av a 2 s . com // ?buffer BufferedImage buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g = buffImg.createGraphics(); // ? g.setColor(Color.WHITE); g.fillRect(0, 0, width, height); // g.setFont(new Font("Arial", Font.PLAIN, fontHeight)); for (int i = 0; i < lineCount; i++) { int xs = RandomUtils.nextInt(0, width); int ys = RandomUtils.nextInt(0, height); int xe = xs + RandomUtils.nextInt(0, width / 8); int ye = ys + RandomUtils.nextInt(0, height / 8); red = RandomUtils.nextInt(0, 255); green = RandomUtils.nextInt(0, 255); blue = RandomUtils.nextInt(0, 255); g.setColor(new Color(red, green, blue)); g.drawLine(xs, ys, xe, ye); } // randomCode??? StringBuilder randomCode = new StringBuilder(); // ?codeCount?? for (int i = 0; i < codeCount; i++) { String strRand = String.valueOf(codeSequence[RandomUtils.nextInt(0, codeSequence.length)]); // ???? red = RandomUtils.nextInt(0, 255); green = RandomUtils.nextInt(0, 255); blue = RandomUtils.nextInt(0, 255); g.setColor(new Color(red, green, blue)); g.drawString(strRand, (i + 1) * x, codeY); // ?? randomCode.append(strRand); } // ????Session return new Pair<String, BufferedImage>(randomCode.toString(), buffImg); }
From source file:flow.visibility.tapping.OpenDayLightUtils.java
/** Creating the Pane for Flow Entry */ public OpenDayLightUtils() { super("Installed Flow"); FlowtextArea = new JTextArea(50, 10); FlowtextArea.setEditable(false);//from www.j av a 2s. c om FlowtextArea.setFont(new Font("Courier New", Font.BOLD, 12)); PrintStream FlowprintStream = new PrintStream(new CustomOutputStream(FlowtextArea)); // re-assigns standard output stream and error output stream System.setOut(FlowprintStream); System.setErr(FlowprintStream); // creates the GUI setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.insets = new Insets(10, 10, 10, 10); constraints.anchor = GridBagConstraints.WEST; constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 2; constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1.0; constraints.weighty = 1.0; /** Adding the Pane into Frame */ scrollPane = new JScrollPane(FlowtextArea); this.add(scrollPane, constraints); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(400, 600); setLocationRelativeTo(null); // centers on screen }
From source file:com.bwc.ora.views.LabelPopupMenu.java
private void initMenu() { //determine if the point clicked already has an annotation boolean hasAnnotationAlready = hasAnnoationAlready(); if (hasAnnotationAlready) { //add label to allow users to deselect the label for a given peak JMenuItem nonItem = new JMenuItem("Remove Label"); nonItem.addActionListener(e -> { removeAnnotation();//w w w . j a v a2 s. c om lrp.setAnnotations(LrpDisplayFrame.getInstance().getAnnotations()); }); add(nonItem); } //add list of possible labels for a point to the popup menu Arrays.stream(RetinalBand.values()).map(RetinalBand::toString).map(label -> { XYPointerAnnotation pointer = new XYPointerAnnotation(label, item.getDataset().getXValue(item.getSeriesIndex(), item.getItem()), item.getDataset().getYValue(item.getSeriesIndex(), item.getItem()), 0); pointer.setBaseRadius(35.0); pointer.setTipRadius(10.0); pointer.setFont(new Font("SansSerif", Font.PLAIN, 9)); pointer.setPaint(Color.blue); pointer.setTextAnchor(TextAnchor.CENTER_LEFT); JMenuItem l = new JMenuItem(label); l.addActionListener(e -> { if (hasAnnotationAlready) { removeAnnotation(); } chartPanel.getChart().getXYPlot().addAnnotation(pointer); lrp.setAnnotations(LrpDisplayFrame.getInstance().getAnnotations()); }); return l; }).forEach(this::add); }
From source file:components.ColorChooserDemo.java
public ColorChooserDemo() { super(new BorderLayout()); //Set up the banner at the top of the window banner = new JLabel("Welcome to the Tutorial Zone!", JLabel.CENTER); banner.setForeground(Color.yellow); banner.setBackground(Color.blue); banner.setOpaque(true);//from ww w. j a v a 2 s. c o m banner.setFont(new Font("SansSerif", Font.BOLD, 24)); banner.setPreferredSize(new Dimension(100, 65)); JPanel bannerPanel = new JPanel(new BorderLayout()); bannerPanel.add(banner, BorderLayout.CENTER); bannerPanel.setBorder(BorderFactory.createTitledBorder("Banner")); //Set up color chooser for setting text color tcc = new JColorChooser(banner.getForeground()); tcc.getSelectionModel().addChangeListener(this); tcc.setBorder(BorderFactory.createTitledBorder("Choose Text Color")); add(bannerPanel, BorderLayout.CENTER); add(tcc, BorderLayout.PAGE_END); }